AMC changes for summary of care and CPOE, see note below:
[openemr.git] / phpmyadmin / normalization.php
blob4cb956918104c7dac53d97accb9f5e31c380c9db
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Normalization process (temporarily specific to 1NF)
6 * @package PhpMyAdmin
7 */
9 /**
12 require_once 'libraries/common.inc.php';
13 require_once 'libraries/transformations.lib.php';
14 require_once 'libraries/normalization.lib.php';
15 require_once 'libraries/Index.class.php';
17 if (isset($_REQUEST['getColumns'])) {
18 $html = '<option selected disabled>' . __('Select oneā€¦') . '</option>'
19 . '<option value="no_such_col">' . __('No such column') . '</option>';
20 //get column whose datatype falls under string category
21 $html .= PMA_getHtmlForColumnsList(
22 $db,
23 $table,
24 _pgettext('string types', 'String')
26 echo $html;
27 exit;
29 if (isset($_REQUEST['splitColumn'])) {
30 $num_fields = $_REQUEST['numFields'];
31 $html = PMA_getHtmlForCreateNewColumn($num_fields, $db, $table);
32 $html .= PMA_URL_getHiddenInputs($db, $table);
33 echo $html;
34 exit;
36 if (isset($_REQUEST['addNewPrimary'])) {
37 $num_fields = 1;
38 $columnMeta = array('Field'=>$table . "_id", 'Extra'=>'auto_increment');
39 $html = PMA_getHtmlForCreateNewColumn(
40 $num_fields, $db, $table, $columnMeta
42 $html .= PMA_URL_getHiddenInputs($db, $table);
43 echo $html;
44 exit;
46 if (isset($_REQUEST['findPdl'])) {
47 $html = PMA_findPartialDependencies($table, $db);
48 echo $html;
49 exit;
52 if (isset($_REQUEST['getNewTables2NF'])) {
53 $partialDependencies = json_decode($_REQUEST['pd']);
54 $html = PMA_getHtmlForNewTables2NF($partialDependencies, $table);
55 echo $html;
56 exit;
59 if (isset($_REQUEST['getNewTables3NF'])) {
60 $dependencies = json_decode($_REQUEST['pd']);
61 $tables = json_decode($_REQUEST['tables']);
62 $newTables = PMA_getHtmlForNewTables3NF($dependencies, $tables, $db);
63 PMA_Response::getInstance()->disable();
64 PMA_headerJSON();
65 echo json_encode($newTables);
66 exit;
69 $response = PMA_Response::getInstance();
70 $header = $response->getHeader();
71 $scripts = $header->getScripts();
72 $scripts->addFile('normalization.js');
73 $scripts->addFile('jquery/jquery.uitablefilter.js');
74 $normalForm = '1nf';
75 if (isset($_REQUEST['normalizeTo'])) {
76 $normalForm = $_REQUEST['normalizeTo'];
78 if (isset($_REQUEST['createNewTables2NF'])) {
79 $partialDependencies = json_decode($_REQUEST['pd']);
80 $tablesName = json_decode($_REQUEST['newTablesName']);
81 $res = PMA_createNewTablesFor2NF($partialDependencies, $tablesName, $table, $db);
82 $response->addJSON($res);
83 exit;
85 if (isset($_REQUEST['createNewTables3NF'])) {
86 $newtables = json_decode($_REQUEST['newTables']);
87 $res = PMA_createNewTablesFor3NF($newtables, $db);
88 $response->addJSON($res);
89 exit;
91 if (isset($_POST['repeatingColumns'])) {
92 $repeatingColumns = $_POST['repeatingColumns'];
93 $newTable = $_POST['newTable'];
94 $newColumn = $_POST['newColumn'];
95 $primary_columns = $_POST['primary_columns'];
96 $res = PMA_moveRepeatingGroup(
97 $repeatingColumns, $primary_columns, $newTable, $newColumn, $table, $db
99 $response->addJSON($res);
100 exit;
102 if (isset($_REQUEST['step1'])) {
103 $html = PMA_getHtmlFor1NFStep1($db, $table, $normalForm);
104 $response->addHTML($html);
105 } else if (isset($_REQUEST['step2'])) {
106 $res = PMA_getHtmlContentsFor1NFStep2($db, $table);
107 $response->addJSON($res);
108 } else if (isset($_REQUEST['step3'])) {
109 $res = PMA_getHtmlContentsFor1NFStep3($db, $table);
110 $response->addJSON($res);
111 } else if (isset ($_REQUEST['step4'])) {
112 $res = PMA_getHtmlContentsFor1NFStep4($db, $table);
113 $response->addJSON($res);
114 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == 2.1) {
115 $res = PMA_getHtmlFor2NFstep1($db, $table);
116 $response->addJSON($res);
117 } else if (isset($_REQUEST['step']) && $_REQUEST['step'] == 3.1) {
118 $tables = $_REQUEST['tables'];
119 $res = PMA_getHtmlFor3NFstep1($db, $tables);
120 $response->addJSON($res);
121 } else {
122 $response->addHTML(PMA_getHtmlForNormalizetable());