migrated ubiquitous libraries to composer autoloader (#421)
[openemr.git] / interface / patient_file / summary / advancedirectives.php
blob83f5463cc4b07a7118652f88922dd6d4cd1e8c30
1 <?php
2 include_once("../../globals.php");
3 include_once("$srcdir/sql.inc");
4 include_once("$srcdir/options.inc.php");
5 ?>
6 <html>
7 <head>
8 <?php html_header_show();?>
9 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js"></script>
10 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
11 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
12 <script type="text/javascript" src="../../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
13 <script type="text/javascript" src="../../../library/textformat.js"></script>
14 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
15 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
16 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
17 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-1/index.js"></script>
18 <SCRIPT LANGUAGE="JavaScript">
19 var mypcc = '<?php echo $GLOBALS['phone_country_code'] ?>';
20 function validate(f) {
21 if (f.form_adreviewed.value == "")
23 alert("<?php xl('Please enter a date for Last Reviewed.','e'); ?>");
24 f.form_adreviewed.focus();
25 return false;
27 return true;
29 $(document).ready(function(){
30 $("#cancel").click(function() { window.close(); });
31 });
32 </script>
33 </head>
35 <body class="body_top">
36 <?php
37 if ($_POST['form_yesno'])
39 sqlQuery("UPDATE patient_data SET completed_ad='".formData('form_yesno','P',true)."', ad_reviewed='".formData('form_adreviewed','P',true)."' where pid='$pid'");
40 // Close this window and refresh the calendar display.
41 echo "<html>\n<body>\n<script language='JavaScript'>\n";
42 echo " if (!opener.closed && opener.refreshme) opener.refreshme();\n";
43 echo " window.close();\n";
44 echo "</script>\n</body>\n</html>\n";
45 exit();
47 $sql = "select completed_ad, ad_reviewed from patient_data where pid='$pid'";
48 $myrow = sqlQuery($sql);
49 if ($myrow)
51 $form_completedad = $myrow['completed_ad'];
52 $form_adreviewed = $myrow['ad_reviewed'];
55 <span class="title"><?php xl('Advance Directives','e'); ?></span>
56 <br><br>
57 <form action='advancedirectives.php' method='post' onsubmit='return validate(this)' enctype="multipart/form-data">
58 <table border=0 cellpadding=1 cellspacing=1>
59 <?php
60 echo "<tr><td class='required'>";
61 xl('Completed','e');
62 echo ":</td><td width=10></td><td class='text'>";
63 generate_form_field(array('data_type'=>1,'field_id'=>'yesno','list_id'=>'yesno','empty_title'=>'SKIP'), $form_completedad);
64 echo "</td></tr><tr><td class='required'>";
65 xl('Last Reviewed','e');
66 echo ":</td><td width=10></td><td class='text'>";
67 generate_form_field(array('data_type'=>4,'field_id'=>'adreviewed'), $form_adreviewed);
68 echo "<script language='JavaScript'>Calendar.setup({inputField:'form_adreviewed', ifFormat:'%Y-%m-%d', button:'img_adreviewed'});</script>";
69 echo "</td></tr>";
70 echo "<tr><td class=text colspan=2><br><input type=submit id=create value='" . xl('Save') . "' /> &nbsp; <input type=button id=cancel value='" . xl('Cancel') . "' /></td></tr>";
72 </table></form>
73 <div>
74 <?php
75 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
76 $myrow2 = sqlQuery($query);
77 if ($myrow2) {
78 $parentId = $myrow2['id'];
79 $query = "SELECT id, name FROM categories WHERE parent='$parentId'";
80 $resNew1 = sqlStatement($query);
81 while ($myrows3 = sqlFetchArray($resNew1)) {
82 $categoryId = $myrows3['id'];
83 $nameDoc = $myrows3['name'];
84 $query = "SELECT documents.date, documents.id " .
85 "FROM documents " .
86 "INNER JOIN categories_to_documents " .
87 "ON categories_to_documents.document_id=documents.id " .
88 "WHERE categories_to_documents.category_id='$categoryId' " .
89 "AND documents.foreign_id='$pid' " .
90 "ORDER BY documents.date DESC";
91 $resNew2 = sqlStatement($query);
92 $counterFlag = false; //flag used to check for empty categories
93 while ($myrows4 = sqlFetchArray($resNew2)) {
94 $dateTimeDoc = $myrows4['date'];
95 $idDoc = $myrows4['id'];
96 echo "<br>";
97 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=$pid&document_id=".$idDoc."&as_file=true'>".xl_document_category($nameDoc)."</a> ".$dateTimeDoc;
98 $counterFlag = true;
100 // if no associated docs with category then show it's empty
101 if (!$counterFlag) {
102 echo "<br>";
103 echo $nameDoc . " <span style='color:red;'>[" . xl('EMPTY') . "]</span>";
108 </div>
109 </body>
110 </html>