* @copyright Copyright (c) 2014 Joe Slam * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3 */ require_once(__DIR__ . "/../../globals.php"); require_once("$srcdir/api.inc"); require_once("$srcdir/forms.inc"); use OpenEMR\Common\Acl\AclMain; use OpenEMR\Core\Header; formHeader("Form: Track anything"); ?> "; // **** DB ACTION ****** $dbaction = isset($_POST['dbaction']) ? trim($_POST['dbaction']) : ''; // save new item to a track //----------------------------- if ($dbaction == 'add') { $the_name = $_POST['name']; $the_descr = $_POST['description']; $the_pos = $_POST['position']; $the_parent = $_POST['parentid']; $the_type = $_POST['the_type']; if ($the_name != null) { $insertspell = "INSERT INTO form_track_anything_type "; $insertspell .= "(name, description, position, parent, active) VALUES (?,?,?,?,?)"; $save_into_db = sqlInsert($insertspell, array($the_name, $the_descr, $the_pos, $the_parent,1)); } else { if ($the_type == 'add') { echo "
\n"; echo xlt('Adding item to track failed') . ". "; echo xlt("Please enter at least the item's name") . "."; echo "

\n"; } if ($the_type == 'create') { echo "
\n"; echo xlt('Creating new track failed') . ". "; echo xlt("Please enter at least the track's name") . "."; echo "

\n"; } } } // end save new item to track ----------------------------- // edit existing track/items //----------------------------- if ($dbaction == 'edit') { $the_name = $_POST['name']; $the_descr = $_POST['description']; $the_pos = $_POST['position']; $the_item = $_POST['itemid']; if ($the_name != null) { $updatespell = "UPDATE form_track_anything_type "; $updatespell .= "SET name = ?, description = ?, position = ? "; $updatespell .= "WHERE track_anything_type_id = ? "; sqlStatement($updatespell, array($the_name, $the_descr, $the_pos, $the_item)); } else { echo "
\n"; echo xlt('Editing failed') . ". "; echo xlt("Field 'name' cannot be NULL") . "."; echo "

\n"; } } // end edit ----------------------------- //----------------------------- if ($dbaction == 'delete' && AclMain::aclCheckCore('admin', 'super')) { $the_item = $_POST['itemid']; $deletespell = "DELETE FROM form_track_anything_type "; $deletespell .= "WHERE track_anything_type_id = ? "; sqlStatement($deletespell, array($the_item)); } // end edit ----------------------------- // *** END DB ACTIONS // Create a new track $create_track = isset($_POST['create_track']) ? trim($_POST['create_track']) : ''; if ($create_track) { echo "
\n"; echo "" . xlt('Create a new track') . "
 "; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . xlt('Name') . "
" . xlt('Description') . "
" . xlt('Position') . "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " onclick="top.restoreSession();location='/interface/forms/track_anything/create.php'"\n"; echo "
\n"; echo "
\n"; } // end create new track // user clicked some buttons... $the_item = isset($_POST['typeid']) ? trim($_POST['typeid']) : ''; if ($the_item) { $add = $_POST['add']; $edit = $_POST['edit']; $delete = $_POST['delete']; $deactivate = $_POST['deact']; $activate = $_POST['act']; // add a new item to track //------------------------ if ($add) { // add item to parent echo "
"; $spell = "SELECT name FROM form_track_anything_type "; $spell .= "WHERE track_anything_type_id = ?"; $myrow = sqlQuery($spell, array($the_item)); echo "
  "; echo xlt('Add item to track') . " " . text($myrow['name']) . "
 \n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . xlt('Name') . "
" . xlt('Description') . "
" . xlt('Position') . "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " onclick="top.restoreSession();location='/interface/forms/track_anything/create.php'"\n"; echo "
\n"; echo "
\n"; }// end add item------------------ if ($edit) { echo "
"; $spell = "SELECT name, description, position FROM form_track_anything_type "; $spell .= "WHERE track_anything_type_id = ?"; $myrow = sqlQuery($spell, array($the_item)); $the_name = $myrow['name']; $the_descr = $myrow['description']; $the_pos = $myrow['position']; echo "
  "; echo xlt('Edit') . " " . text($the_name) . "
 "; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
" . xlt('Name') . "
" . xlt('Description') . "
" . xlt('Position') . "
\n"; echo "\n"; echo "\n"; echo "\n"; echo " onclick="top.restoreSession();location='/interface/forms/track_anything/create.php'"\n"; echo "
\n"; echo "
\n"; } if ($delete) { echo "
\n"; $spell = "SELECT name FROM form_track_anything_type "; $spell .= "WHERE track_anything_type_id = ?"; $myrow = sqlQuery($spell, array($the_item)); $the_name = $myrow['name']; echo "
  \n"; echo xlt('Are you sure you want to delete') . " " . text($the_name) . "?
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "  \n"; echo "   onclick="top.restoreSession();location='/interface/forms/track_anything/create.php'"\n"; echo "


\n"; echo "
\n"; } if ($deactivate) { // deactive the item/track $updatespell = "UPDATE form_track_anything_type "; $updatespell .= "SET active = '0' "; $updatespell .= "WHERE track_anything_type_id = ? "; sqlStatement($updatespell, array($the_item)); } if ($activate) { // activate the item/track $updatespell = "UPDATE form_track_anything_type "; $updatespell .= "SET active = '1' "; $updatespell .= "WHERE track_anything_type_id = ? "; sqlStatement($updatespell, array($the_item)); } } //end user clicked button // ================================================================0 // Here comes the page... echo "
  \n"; echo xlt('Create and modify tracks'); echo "

\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // get all track-setups $spell = "SELECT * FROM form_track_anything_type "; $spell .= "WHERE parent = 0 "; $spell .= "ORDER BY position ASC, active DESC, name ASC"; $result = sqlStatement($spell); while ($myrow = sqlFetchArray($result)) { $type_id = $myrow['track_anything_type_id']; $type_name = $myrow['name']; $type_pos = $myrow['position']; $type_descr = $myrow['description']; $type_active = $myrow['active']; echo "\n"; echo "\n"; if ($type_active == '1') { echo "\n"; echo "\n"; echo "\n"; } elseif ($type_active == '0') { echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; $spell2 = "SELECT * FROM form_track_anything_type "; $spell2 .= "WHERE parent = ? "; $spell2 .= "ORDER BY position ASC, active DESC, name ASC"; $result2 = sqlStatement($spell2, array($type_id)); while ($myrow2 = sqlFetchArray($result2)) { $item_id = $myrow2['track_anything_type_id']; $item_name = $myrow2['name']; $item_pos = $myrow2['position']; $item_descr = $myrow2['description']; $item_active = $myrow2['active']; echo "\n"; echo "\n"; if ($item_active == '1') { echo "\n"; echo "\n"; echo "\n"; } elseif ($item_active == '0') { echo "\n"; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; } // end while $myrow2 echo "\n"; } // end while $myrow echo "
" . xlt('Name') . "" . xlt('Description') . "" . xlt('Pos{{Abbreviation for Position}}') . ". 
  " . text($type_name) . "  " . text($type_descr) . "  " . text($type_pos) . "  " . text($type_name) . "  " . text($type_descr) . "  " . text($type_pos) . ""; echo "\n"; echo "\n"; if ($type_active == '1') { echo "\n"; } elseif ($type_active == '0') { echo "\n"; } if (AclMain::aclCheckCore('admin', 'super')) { echo "\n"; } echo ""; echo "
     | " . text($item_name) . "     | " . text($item_descr) . "     | " . text($item_pos) . "     | " . text($item_name) . "     | " . text($item_descr) . "     | " . text($item_pos) . ""; echo "\n"; if ($item_active == '1') { echo "\n"; } elseif ($item_active == '0') { echo "\n"; } if (AclMain::aclCheckCore('admin', 'super')) { echo "\n"; } echo "\n"; echo "
\n"; echo "

\n"; echo "

\n"; echo "\n"; echo " onclick="top.restoreSession();location='/interface/forms/track_anything/new.php'" onclick="top.restoreSession();location='/interface/patient_file/summary/demographics.php'" onclick="top.restoreSession();location='/interface/new/new.php'"\n"; echo "

\n"; echo "
\n"; echo "\n"; ?>