From 678a3e5b3c8a87048d9b3dd6038eb7ac11e19189 Mon Sep 17 00:00:00 2001
From: cfapress
Date: Fri, 13 Feb 2009 22:11:29 +0000
Subject: [PATCH] enhanced UI
---
interface/super/edit_layout.php | 997 +++++++++++++++++++++++++++--------
interface/super/edit_list.php | 208 ++++++--
interface/super/show_lists_popup.php | 75 +++
3 files changed, 1020 insertions(+), 260 deletions(-)
rewrite interface/super/edit_layout.php (60%)
create mode 100644 interface/super/show_lists_popup.php
diff --git a/interface/super/edit_layout.php b/interface/super/edit_layout.php
dissimilarity index 60%
index 663f8c40c..4764eac37 100644
--- a/interface/super/edit_layout.php
+++ b/interface/super/edit_layout.php
@@ -1,212 +1,785 @@
-
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License
-// as published by the Free Software Foundation; either version 2
-// of the License, or (at your option) any later version.
-
-require_once("../globals.php");
-require_once("$srcdir/acl.inc");
-
-$layouts = array(
- 'DEM' => xl('Demographics'),
- 'HIS' => xl('History'),
- 'REF' => xl('Referrals'),
-);
-if ($GLOBALS['ippf_specific']) {
- $layouts['GCA'] = xl('Abortion Issues');
- $layouts['CON'] = xl('Contraception Issues');
- $layouts['SRH'] = xl('SRH Visit Form');
-}
-
-$layout_id = empty($_REQUEST['layout_id']) ? 'DEM' : $_REQUEST['layout_id'];
-
-// Check authorization.
-$thisauth = acl_check('admin', 'super');
-if (!$thisauth) die("Not authorized.");
-
-$fld_line_no = 0;
-
-// Write one option line to the form.
-//
-function writeFieldLine($field_id, $group, $title, $seq, $uor, $length,
- $titlecols, $datacols, $default, $desc, $data_type)
-{
- global $fld_line_no;
- ++$fld_line_no;
- $bgcolor = "#" . (($fld_line_no & 1) ? "ddddff" : "ffdddd");
- $checked = $default ? " checked" : "";
-
- echo " \n";
-
- echo " ";
- echo $field_id;
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo " ";
- if ($data_type == 2) {
- echo "";
- } else {
- echo " ";
- }
- echo " | \n";
-
- echo " ";
- echo "";
- echo " | \n";
-
- echo "
\n";
-}
-?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+
+require_once("../globals.php");
+require_once("$srcdir/acl.inc");
+
+$layouts = array(
+ 'DEM' => xl('Demographics'),
+ 'HIS' => xl('History'),
+ 'REF' => xl('Referrals'),
+);
+if ($GLOBALS['ippf_specific']) {
+ $layouts['GCA'] = xl('Abortion Issues');
+ $layouts['CON'] = xl('Contraception Issues');
+ $layouts['SRH'] = xl('SRH Visit Form');
+}
+
+// array of the data_types of the fields
+$datatypes = array("1"=>"list box",
+ "2"=>"textbox",
+ "3"=>"textarea",
+ "4"=>"text-date",
+ "10"=>"Providers",
+ "11"=>"Providers NPI",
+ "12"=>"Pharmacies",
+ "13"=>"Squads",
+ "14"=>"Organizations",
+ "15"=>"Billing codes",
+ "21"=>"checkbox list",
+ "22"=>"textbox list",
+ "23"=>"Exam results",
+ "24"=>"Patient allergies",
+ "25"=>"checkbox w/ text"
+ );
+
+// Check authorization.
+$thisauth = acl_check('admin', 'super');
+if (!$thisauth) die("Not authorized.");
+
+// the layout ID defaults to DEM (demographics)
+$layout_id = empty($_REQUEST['layout_id']) ? 'DEM' : $_REQUEST['layout_id'];
+
+// Handle the Form actions
+
+if ($_POST['formaction']=="save" && $layout_id) {
+ // If we are saving, then save.
+ $fld = $_POST['fld'];
+ for ($lino = 1; isset($fld["$lino"]['id']); ++$lino) {
+ $iter = $fld["$lino"];
+ $field_id = trim($iter['id']);
+ if ($field_id) {
+ sqlStatement("UPDATE layout_options SET " .
+ "title = '" . trim($iter['title']) . "', " .
+ "group_name = '" . trim($iter['group']) . "', " .
+ "seq = '" . trim($iter['seq']) . "', " .
+ "uor = '" . trim($iter['uor']) . "', " .
+ "fld_length = '" . trim($iter['length']) . "', " .
+ "titlecols = '" . trim($iter['titlecols']) . "', " .
+ "datacols = '" . trim($iter['datacols']) . "', " .
+ "data_type= '" . trim($iter['data_type']) . "', " .
+ "list_id= '" . trim($iter['list_id']) . "', " .
+ "default_value = '" . trim($iter['default']) . "', " .
+ "description = '" . trim($iter['desc']) . "' " .
+ "WHERE form_id = '$layout_id' AND field_id = '$field_id'");
+ }
+ }
+}
+
+else if ($_POST['formaction']=="addfield" && $layout_id) {
+ // Add a new field to a specific group
+ sqlStatement("INSERT INTO layout_options (".
+ "form_id, field_id, title, group_name, seq, uor, fld_length ".
+ ",titlecols, datacols, data_type, default_value, description ".
+ ", max_length".
+ ") VALUES (".
+ "'".trim($_POST['layout_id'])."'".
+ ",'".trim($_POST['newid'])."'".
+ ",'".trim($_POST['newtitle'])."'".
+ ",'".trim($_POST['newfieldgroupid'])."'".
+ ",'".trim($_POST['newseq'])."'".
+ ",'".trim($_POST['newuor'])."'".
+ ",'".trim($_POST['newlength'])."'".
+ ",'".trim($_POST['newtitlecols'])."'".
+ ",'".trim($_POST['newdatacols'])."'".
+ ",'".trim($_POST['newdatatype'])."'".
+ ",'".trim($_POST['newdefault'])."'".
+ ",'".trim($_POST['newdesc'])."'".
+ ",'".trim($_POST['newlength'])."'". // maxlength = length
+ ")");
+
+}
+
+else if ($_POST['formaction']=="deletefield" && $layout_id) {
+ // Delete a field from a specific group
+ sqlStatement("DELETE FROM layout_options WHERE ".
+ " form_id = '".$_POST['layout_id']."' ".
+ " AND field_id = '".$_POST['deletefieldid']."'".
+ " AND group_name = '".$_POST['deletefieldgroup']."'"
+ );
+}
+
+else if ($_POST['formaction']=="addgroup" && $layout_id) {
+ // all group names are prefixed with a number indicating their display order
+ // this new group is prefixed with the net highest number given the
+ // layout_id
+ $results = sqlStatement("select distinct(group_name) as gname ".
+ " from layout_options where ".
+ " form_id = '".$_POST['layout_id']."'"
+ );
+ $maxnum = 0;
+ while ($result = sqlFetchArray($results)) {
+ // split the number from the group name
+ $parts = preg_split("/([A-Z]|[a-z])/", $result['gname']);
+ if ($parts[0] >= $maxnum) { $maxnum = $parts[0] + 1; }
+ }
+
+ // add a new group to the layout, with a default field
+ sqlStatement("INSERT INTO layout_options (".
+ "form_id, field_id, title, group_name".
+ ") VALUES (".
+ "'".trim($_POST['layout_id'])."'".
+ ",'newfield'".
+ ",'newfield'".
+ ",'".trim($maxnum . $_POST['newgroupname'])."'".
+ ")");
+}
+
+else if ($_POST['formaction']=="deletegroup" && $layout_id) {
+ // Delete an entire group from the form
+ sqlStatement("DELETE FROM layout_options WHERE ".
+ " form_id = '".$_POST['layout_id']."' ".
+ " AND group_name = '".$_POST['deletegroupname']."'"
+ );
+}
+
+else if ($_POST['formaction']=="movegroup" && $layout_id) {
+
+ // split the numeric order out of the group name
+ $parts = preg_split("/(^\d)/", $_POST['movegroupname'], -1, PREG_SPLIT_DELIM_CAPTURE);
+ $currpos = $newpos = $parts[1];
+ $groupname = $parts[2];
+
+ // inc/dec the order number
+ if ($_POST['movedirection'] == 'up') {
+ $newpos--;
+ if ($newpos < 0) { $newpos = 0; }
+ }
+ else if ($_POST['movedirection'] == 'down') {
+ $newpos++;
+ }
+
+ // if we can't determine a position, then assign it a zero
+ if ($newpos == "") $newpos = "0";
+
+ // update the database rows
+ sqlStatement("UPDATE layout_options SET ".
+ "group_name='".$newpos.$groupname."'".
+ " WHERE ".
+ "group_name='".$currpos.$groupname."'"
+ );
+}
+
+else if ($_POST['formaction']=="renamegroup" && $layout_id) {
+
+ // split the numeric order out of the group name
+ $parts = preg_split("/(^\d)/", $_POST['renameoldgroupname'], -1, PREG_SPLIT_DELIM_CAPTURE);
+ $currpos = $parts[1];
+
+ // if we can't determine a position, then assign it a zero
+ if ($currpos == "") $currpos = "0";
+
+ // update the database rows
+ sqlStatement("UPDATE layout_options SET ".
+ "group_name='".$currpos.$_POST['renamegroupname']."'".
+ " WHERE ".
+ "group_name='".$_POST['renameoldgroupname']."'"
+ );
+}
+
+
+// Get the selected form's elements.
+if ($layout_id) {
+ $res = sqlStatement("SELECT * FROM layout_options WHERE " .
+ "form_id = '$layout_id' ORDER BY group_name, seq");
+}
+
+
+// global counter for field numbers
+$fld_line_no = 0;
+
+// Write one option line to the form.
+//
+function writeFieldLine($linedata) {
+ global $fld_line_no;
+ ++$fld_line_no;
+ $checked = $linedata['default_value'] ? " checked" : "";
+
+ //echo " \n";
+ echo "
\n";
+
+ echo " ";
+ // tuck the group_name INPUT in here
+ echo "";
+ echo "";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | ";
+
+ echo " ";
+ if ($linedata['data_type'] == 2 || $linedata['data_type'] == 3)
+ {
+ // textbox or textarea
+ echo "";
+ echo "";
+ }
+ else if ($linedata['data_type'] == 4) {
+ // text-date
+ echo "";
+ echo "(date)";
+ }
+ else if ($linedata['data_type'] == 1 || $linedata['data_type'] == 21 ||
+ $linedata['data_type'] == 22 || $linedata['data_type'] == 25)
+ {
+ // select, checkbox, textbox list, or checkbox list w/ text
+ echo "";
+ echo "";
+ }
+ else {
+ // all other data_types
+ echo "";
+ if ($linedata['list_id'] != "") {
+ echo "(list)";
+ }
+ }
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo " ";
+ if ($linedata['data_type'] == 2) {
+ echo "";
+ } else {
+ echo " ";
+ }
+ echo " | \n";
+
+ echo " ";
+ echo "";
+ echo " | \n";
+
+ echo "
\n";
+}
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Group Name:
+
+
+
+
+
+
+
+Group Name:
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/interface/super/edit_list.php b/interface/super/edit_list.php
index fc41ee575..c92319831 100644
--- a/interface/super/edit_list.php
+++ b/interface/super/edit_list.php
@@ -16,6 +16,78 @@ $list_id = empty($_REQUEST['list_id']) ? 'language' : $_REQUEST['list_id'];
$thisauth = acl_check('admin', 'super');
if (!$thisauth) die("Not authorized.");
+// If we are saving, then save.
+//
+if ($_POST['formaction']=='save' && $list_id) {
+ $opt = $_POST['opt'];
+ if ($list_id == 'feesheet') {
+ // special case for the feesheet list
+ sqlStatement("DELETE FROM fee_sheet_options");
+ for ($lino = 1; isset($opt["$lino"]['category']); ++$lino) {
+ $iter = $opt["$lino"];
+ $category = trim($iter['category']);
+ $option = trim($iter['option']);
+ $codes = $iter['codes'];
+ if (strlen($category) > 0 && strlen($option) > 0) {
+ sqlInsert("INSERT INTO fee_sheet_options ( " .
+ "fs_category, fs_option, fs_codes " .
+ ") VALUES ( " .
+ "'$category', " .
+ "'$option', " .
+ "'$codes' " .
+ ")");
+ }
+ }
+ }
+ else {
+ // all other lists
+ //
+ // erase lists options and recreate them from the submitted form data
+ sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
+ for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
+ $iter = $opt["$lino"];
+ $value = empty($iter['value']) ? 0 : (trim($iter['value']) + 0);
+ if (strlen(trim($iter['id'])) > 0) {
+ sqlInsert("INSERT INTO list_options ( " .
+ "list_id, option_id, title, seq, is_default, option_value " .
+ ") VALUES ( " .
+ "'$list_id', " .
+ "'" . trim($iter['id']) . "', " .
+ "'" . trim($iter['title']) . "', " .
+ "'" . trim($iter['seq']) . "', " .
+ "'" . trim($iter['default']) . "', " .
+ "'" . $value . "' " .
+ ")");
+ }
+ }
+ }
+}
+else if ($_POST['formaction']=='addlist') {
+ // make a new list ID from the new list name
+ $newlistID = $_POST['newlistname'];
+ $newlistID = preg_replace("/\W/", "_", $newlistID);
+
+ // determine the position of this new list
+ $row = sqlQuery("SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'");
+
+ // add the new list to the list-of-lists
+ sqlInsert("INSERT INTO list_options ( " .
+ "list_id, option_id, title, seq, is_default, option_value " .
+ ") VALUES ( " .
+ "'lists',". // the master list-of-lists
+ "'".$newlistID."',".
+ "'".$_POST['newlistname']."', ".
+ "'".($row['maxseq']+1)."',".
+ "'1', '0')"
+ );
+}
+else if ($_POST['formaction']=='deletelist') {
+ // delete the lists options
+ sqlStatement("DELETE FROM list_options WHERE list_id = '".$_POST['list_id']."'");
+ // delete the list from the master list-of-lists
+ sqlStatement("DELETE FROM list_options WHERE list_id = 'lists' and option_id='".$_POST['list_id']."'");
+}
+
$opt_line_no = 0;
// Given a string of multiple instances of code_type|code|selector,
@@ -135,6 +207,9 @@ function writeFSLine($category, $option, $codes) {
+
+
+
@@ -223,55 +298,12 @@ function set_related(codetype, code, selector, codedesc) {
- 0 && strlen($option) > 0) {
- sqlInsert("INSERT INTO fee_sheet_options ( " .
- "fs_category, fs_option, fs_codes " .
- ") VALUES ( " .
- "'$category', " .
- "'$option', " .
- "'$codes' " .
- ")");
- }
- }
- }
- else {
- sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
- for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
- $iter = $opt["$lino"];
- $value = empty($iter['value']) ? 0 : (trim($iter['value']) + 0);
- if (strlen(trim($iter['id'])) > 0) {
- sqlInsert("INSERT INTO list_options ( " .
- "list_id, option_id, title, seq, is_default, option_value " .
- ") VALUES ( " .
- "'$list_id', " .
- "'" . trim($iter['id']) . "', " .
- "'" . trim($iter['title']) . "', " .
- "'" . trim($iter['seq']) . "', " .
- "'" . trim($iter['default']) . "', " .
- "'" . $value . "' " .
- ")");
- }
- }
- }
-}
-?>
-
@@ -335,10 +370,87 @@ if ($list_id) {
- ' />
+ ' />
+
+
+
+List Name:
+
+
+
+
+
+
diff --git a/interface/super/show_lists_popup.php b/interface/super/show_lists_popup.php
new file mode 100644
index 000000000..dc731c7ce
--- /dev/null
+++ b/interface/super/show_lists_popup.php
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Active lists
+
+".$row['title']."";
+}
+?>
+
+
+
+
+
+
+
--
2.11.4.GIT