Просмотр исходного кода

Upload files to 'public_html/scripts'

david.ortiz11 4 лет назад
Родитель
Сommit
795f35d3b2

+ 57
- 49
public_html/scripts/extract.php Просмотреть файл

@@ -5,29 +5,29 @@
5 5
     Organization    :   Centro de Desarrollo y Consultoria Computacional
6 6
     Project         :   OPASO Material Registry   
7 7
     File            :   extract.php
8
-    Description     :   Extract and insert data from tsv. */
8
+    Description     :   Extract and insert data from tsv */
9 9
 
10
-	/* Import database connection & display errors */
11
-	include_once "config.php";
10
+	/* database connection */
11
+	include_once "../config/database.php";
12 12
 	error_reporting(E_ALL);
13 13
 	ini_set("display_errors",1);
14
-	/* For each file: open and explode each row by tabs */
15
-	foreach (glob("../ndata/*.txt") as $file){
16
-		/* Initiate laboratory/personnel/register dictionaries. */ 
14
+
15
+	/* for each file: open and explode each row by tabs */
16
+	foreach (glob("") as $file){
17 17
 		$laboratory = array();
18 18
 		$pi = array();
19 19
 		$cho = array();
20 20
 		$register = array();
21
-		/* Initiate some values. */ 
22 21
 		$success = 0;
23 22
 		$null = "n/a";
24
-		$row = 1;	/* Start at row 1. */	
23
+		$row = 1;
24
+
25 25
 		/* Parse tsv file */
26 26
 		if(($fhandle = fopen($file,"r")) !== FALSE){
27 27
 	  		while(($data = fgetcsv($fhandle,1000,"\t")) !== FALSE){
28
-				/* Extract department and personnel in columns B(1) and I(8) */ 
28
+				/* extract department and personnel in columns B(1) and I(8) */ 
29 29
 				if($row > 6 and $row < 12){
30
-					/* Avoid null keys. */
30
+					/* avoid null keys */
31 31
 					if($data[0]){
32 32
 						$laboratory[$data[0]] = $data[1];
33 33
 					}
@@ -38,67 +38,67 @@
38 38
 						$cho[$data[7]] = $data[8];
39 39
 					}
40 40
 				}
41
-				/* Extract cho phone. */ 
41
+
42
+				/* cho phone */ 
42 43
 				elseif($row == 12){
43 44
 					$cho[$data[7]] = $data[8];
44 45
 				}
45
-				/* Insert laboratory/personnel info and generate register keys. */ 
46
+
47
+				/* generate register keys */ 
46 48
 				elseif($row == 14){
47 49
 					for($index=0; $index < count($data); $index++){
48
-						/* Initiate keys with null values. */
49 50
 						if($data[$index]){
50 51
 							$register[$data[$index]] = "";
51 52
 						}
52 53
 					}
54
+
53 55
 					foreach($pi as $key=>&$value){
54 56
 						if(!$value){
55 57
 							$value = $null;
56 58
 						}
57 59
 					}
60
+
58 61
 					foreach($cho as $key=>&$value){
59 62
 						if(!$value){
60 63
 							$value = $null;
61 64
 						}
62 65
 					}
63
-					/* person entries. 
64
-					   Bind and insert pi data. */
66
+
67
+					/* person entries */
65 68
 					$person = $db->stmt_init();
66 69
 					if($person = $db->prepare("INSERT INTO Person(pname,email,password,phone,privileges) VALUES (?,?,?,?,?)")){
67
-						$person->bind_param("sssss",$pi['pi'],$pi['piemail'],$null,$pi['piphone'],$null);
70
+						$person->bind_param("sssss",$pi["pi"],$pi["piemail"],$null,$pi["piphone"],$null);
68 71
 						if($person->execute()){
69
-							$pi = $db->insert_id;	/* Extract generated pid. */
72
+							$pi = $db->insert_id;
70 73
 						}
71
-						/* In case of duplicate entry. */ 
74
+						/* duplicate entry */ 
72 75
 						else{
73 76
 							$email = $pi['piemail'];
74
-							/* Extract id by email. */
75 77
 							if ($person = $db->prepare("SELECT pid FROM Person WHERE email=?")){
76
-							    /* Bind selector and execute. */
77 78
 							    $person->bind_param("s",$email);
78 79
 							    if($person->execute()){
79
-				    				/* Bind result variables and fetch. */
80 80
 								    $person->bind_result($pi);
81 81
 								    $person->fetch();
82 82
 							    }
83 83
 							}
84 84
 						}
85 85
 					}
86
-					/* Bind and insert cho data. */
86
+
87
+					/* cho */
87 88
 					$person = $db->stmt_init();
88 89
 					if($person = $db->prepare("INSERT INTO Person(pname,email,password,phone,privileges) VALUES (?,?,?,?,?)")){
89
-						$person->bind_param("sssss",$cho['cho'],$cho['choemail'],$null,$cho['chophone'],$null);
90
+						$person->bind_param("sssss",$cho["cho"],$cho["choemail"],$null,$cho["chophone"],$null);
91
+						
90 92
 						if($person->execute()){
91
-							$cho = $db->insert_id;	/* Extract generated pid. */
93
+							$cho = $db->insert_id;
92 94
 						}
93
-						/* In case of duplicate entry. */ 
95
+
96
+						/* duplicate entry */ 
94 97
 						else{
95 98
 							$email = $cho['choemail'];
96
-							/* Extract id by email. */
97 99
 							if ($person = $db->prepare("SELECT pid FROM Person WHERE email=?")){
98
-							    /* Bind selector and execute. */
99 100
 							    $person->bind_param("s",$email);
100 101
 							    if($person->execute()){
101
-				    				/* Bind result variables and fetch. */
102 102
 								    $person->bind_result($cho);
103 103
 								    $person->fetch();
104 104
 							    }
@@ -106,40 +106,45 @@
106 106
 						}
107 107
 					}
108 108
 					$person->close();
109
-					/* lab entry
110
-					   Bind and insert lab data. */ 
109
+
110
+					/* lab entry */
111 111
 					$lab = $db->stmt_init();
112 112
 					if($lab = $db->prepare("INSERT INTO Laboratory(lname,lab,department,building,extension,pi,cho) VALUES (?,?,?,?,?,?,?)")){
113
-						$lab->bind_param("sssssii",$laboratory['lname'],$laboratory['lab'],$laboratory['department'],$laboratory['building'],$laboratory['extension'],$pi,$cho);
113
+						$lab->bind_param("sssssii",$laboratory["lname"],$laboratory["lab"],$laboratory["department"],$laboratory["building"],$laboratory["extension"],$pi,$cho);
114 114
 						$lab->execute();
115 115
 						$lab->close();
116
-						$lab = $db->insert_id;	/* Extract generated lid. */
116
+						/* extract generated lab_id */
117
+						$lab_id = $db->insert_id;
117 118
 					}
118 119
 				}
119
-				/* Extract register data by row. */ 
120
+
121
+				/* extract register data by row */ 
120 122
 				elseif($row > 15){
121
-					$d = 0;	/* Reset index. */
123
+					/* reset index */
124
+					$d = 0;
122 125
 					foreach($register as $key=>&$value){
123
-						/* Replace null entries with identifiable string. */ 
124 126
 						if($data[$d]){
125 127
 							$value = $data[$d];
126 128
 						}
127 129
 						else{
128 130
 							$value = $null;
129 131
 						}
130
-						$d++;
131
-						/* Avoid segmentation fault. */ 
132
+
133
+						$d += 1;
134
+
135
+						/* avoid seg fault */ 
132 136
 						if($d >= count($register)){
133 137
 							break;	
134 138
 						}
135 139
 					}
136
-					/* inventory entries
137
-					   Bind and insert inventory data. */ 
140
+
141
+					/* inventory entries */ 
138 142
 					$inventory = $db->stmt_init();
139 143
 					if($register['chemical'] != "null entry"){
140 144
 						if($inventory = $db->prepare("INSERT INTO Inventory(chemical,manufacturer,sds,cas,state,hazard,type,amount,quantity,total,location,ghs,lid) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)")){
141
-					 		$inventory->bind_param("ssssssssssssi",$register['chemical'],$register['manufacturer'],$register['sds'],$register['cas'],$register['state'],$register['hazard'],$register['type'],$register['amount'],$register['quantity'],$register['total'],$register['location'],$register['ghs'],$lab);
142
-							/* Query failed, display error. */ 
145
+					 		$inventory->bind_param("ssssssssssssi",$register["chemical"],$register["manufacturer"],$register["sds"],$register["cas"],$register["state"],$register["hazard"],$register["type"],$register["amount"],$register["quantity"],$register["total"],$register["location"],$register["ghs"],$lab_id);
146
+
147
+							/* query failed */ 
143 148
 							if(!($inventory->execute())){
144 149
 								echo "Entry error:";
145 150
 								echo "<br>";
@@ -149,27 +154,30 @@
149 154
 					 			echo "<br>";
150 155
 								echo "PI id: " . $pi . "<br>";
151 156
 								echo "CHO id: " . $cho . "<br>";
152
-								echo "LAB id: " . $lab . "<br>";
157
+								echo "LAB id: " . $lab_id . "<br>";
153 158
 							}
154
-							/* Track number of successful entries. */ 
159
+
160
+							/* successful entries */ 
155 161
 							else{
156
-								$success++;
162
+								$success += 1;
157 163
 								$inventory->close();
158 164
 							}
159 165
 						}
160 166
 					}
161 167
 				}
162
-		    	$row++;		/* Update row. */ 
168
+
169
+				/* update row */ 
170
+		    	$row += 1;
163 171
 		  	}
164
-		  	/* Close all remaining connections/streams. */ 
172
+
165 173
 		  	fclose($fhandle);
166 174
 			echo "<br>FILE: " . $file . "<br>";
167 175
 			echo "PI id: " . $pi . "<br>";
168 176
 			echo "CHO id: " . $cho . "<br>";
169
-			echo "LAB id: " . $lab . "<br>";
177
+			echo "LAB id: " . $lab_id . "<br>";
170 178
 			echo $success . " successful entries." . "<br><br>";
171 179
 		}
172 180
 	}
173
-	/* Close db connection. */ 
181
+
174 182
 	$db->close();
175
-?>
183
+?>

+ 191
- 0
public_html/scripts/offered.js Просмотреть файл

@@ -0,0 +1,191 @@
1
+/*  Authors         :   Carlos C. Corrada-Bravo
2
+                        David J. Ortiz-Rivera
3
+
4
+    Organization    :   Centro de Desarrollo y Consultoria Computacional
5
+    Project         :   OPASO Material Registry   
6
+    File            :   offered.js
7
+    Description     :   Generate offered materials table */
8
+
9
+/* global values */
10
+var i;
11
+var next = 0;
12
+var person_id;
13
+var offered = {};
14
+
15
+/* fetch offered materials */ 
16
+$(document).ready(fetch_labs);
17
+
18
+/* set_listeners() - listen for events */
19
+function set_listeners(){
20
+    /* confirm request */
21
+    $(".request").click(function(){
22
+        i = $(this).attr("value");
23
+        $(".form-message").text(`Request ${offered[i]["amount"]} of ${offered[i]["material"]["mat_name"]}?`);
24
+        display_form();
25
+    });
26
+
27
+    /* send request */
28
+    $(".submit").click(function(){
29
+        hide_form();
30
+        let r_lab_id = $(".labs").val();
31
+        $.post("/scripts/opaso",{query: 28,person_id: person_id,lab_id: r_lab_id,request: JSON.stringify(offered[i])},function(data){
32
+            // console.log(data);
33
+            /* extract response */
34
+            let response = JSON.parse(data);
35
+            let status = response["status"];
36
+
37
+            /* handle by status */
38
+            switch(status){
39
+                case "expired":                  /* on expired, redirect to index */
40
+                    window.location.href = "/?error=session_expired";
41
+                    break;
42
+
43
+                default:                        /* on success/error, display message */
44
+                    set_alert(status,response["message"]);
45
+                    break;
46
+            }
47
+        });
48
+    });
49
+
50
+    /* close form */ 
51
+    $(".close-form").click(function(e){
52
+        /* prevent child propagation */
53
+        if(e.target !== e.currentTarget){
54
+            return;
55
+        }
56
+        /* hide form */
57
+        hide_form();
58
+    });
59
+}
60
+
61
+/* display_form() - display form */
62
+function display_form(){
63
+    $(".form-shader").addClass("fade-in");
64
+    $(".lab-form").addClass("slide-down");
65
+}
66
+
67
+/* hide_form() - hide form  */
68
+function hide_form(){
69
+    $(".lab-form").removeClass("slide-down");
70
+    setTimeout(function(){
71
+        $(".form-shader").removeClass("fade-in");
72
+    },250);
73
+}
74
+
75
+/* table_gen(data: dictionary) - generate table body */
76
+function table_gen(data){
77
+    /* extract entries */
78
+    for(var d in data){
79
+        let tr = element_gen("tr",{id: d});
80
+        let fs = data[d];
81
+        for(var f in fs){
82
+            switch(f){
83
+                case "person":          /* extract id */
84
+                    var attrs = {person_id: fs[f]["person_id"],value: "person_name", text: fs[f]["person_name"]};
85
+                    break;
86
+                
87
+                case "manufacturer":    /* extract id */
88
+                    if(!fs[f]["man_name"]){
89
+                        fs[f]["man_name"] = "-";
90
+                    }
91
+
92
+                    var attrs = {man_id: fs[f]["man_id"],value: "man_name", text: fs[f]["man_name"]};
93
+                    break;
94
+
95
+                case "material":        /* extract id */
96
+                    var href = `/materials?mat_id=${fs[f]["mat_id"]}`;
97
+                    var link = element_gen("a",{class: "mat-link",target: "_blank",rel: "noopener noreferrer",text: fs[f]["mat_name"],href: href});
98
+                    var attrs = {value: "mat_name",childs: {link}};
99
+                    break;
100
+
101
+                case "lab":             /* extract id */
102
+                    var href = `/laboratory?lab_id=${fs[f]["lab_id"]}`;
103
+                    var link = element_gen("a",{class: "lab-link",target: "_blank",rel: "noopener noreferrer",text: fs[f]["lab_room"],href: href});
104
+                    var attrs = {value: "lab_room",childs: {link}};
105
+                    break;
106
+
107
+                default:                /* default */
108
+                    var attrs = {text: fs[f],value: f};
109
+                    break;
110
+            }
111
+
112
+            var td = element_gen("td",attrs);
113
+            tr.append(td);
114
+        }
115
+
116
+        let icon =element_gen("i",{class: "request-icon material-icons", text: "notes"});
117
+        let button = element_gen("button",{class: "action request",value: d,title: "request",childs: {icon}});
118
+        var td = element_gen("td",{value: "action",childs:{button}});
119
+        tr.append(td);
120
+        $("tbody").append(tr);
121
+    }
122
+
123
+    $(".processing").hide();
124
+    setTimeout(function(){
125
+        set_listeners();
126
+        $(".main-wrapper").show();
127
+    },250);
128
+}
129
+
130
+/* fetch_materials() - fetch offered materials */ 
131
+function fetch_materials(){
132
+    $.post("/scripts/opaso",{query: 27},function(data){
133
+        // console.log(data);
134
+        /* extract response */
135
+        let response = JSON.parse(data);
136
+        let status = response["status"];
137
+
138
+        /* handle by status */
139
+        switch(status){
140
+            case "success":                 /* on success, generate table */
141
+                var date = new Date();
142
+                date = date.toString().split(" ").splice(1,4).join(" ");
143
+                offered = response["offered"];
144
+                person_id = response["person_id"];
145
+                next = Object.keys(offered).length;
146
+                $(".sub-header").text(`As of: ${date}`);
147
+                $(".table-total").text(`Total: ${next}`);
148
+                table_gen(offered);
149
+                break;
150
+            
151
+            case "expired":                 /* on expired, redirect to index */
152
+                window.location.href = "/?error=session_expired";
153
+                break;
154
+
155
+            default:                        /* on error, display message */
156
+                set_alert(status,response["message"]);
157
+                break;
158
+        }
159
+    });
160
+}
161
+
162
+/* fetch_labs() - fetch authorized labs */
163
+function fetch_labs(){
164
+    $.post("/scripts/opaso",{query: 2},function(data){
165
+        // console.log(data);
166
+        /* extract response */
167
+        let response = JSON.parse(data);
168
+        let status = response["status"];
169
+
170
+        /* handle by status */
171
+        switch(status){
172
+            case "success":                 /* on success, generate authorized labs form */
173
+                let auth = response["authorized"];
174
+                for(var lab in auth){
175
+                    var option = element_gen("option",{class: "lab",value: auth[lab]["lab_id"],text: auth[lab]["lab_room"]});
176
+                    $(".labs").append(option);
177
+                }
178
+
179
+                fetch_materials();
180
+                break;
181
+
182
+            case "expired":                  /* on expired, redirect to index */
183
+                window.location.href = "/?error=session_expired";
184
+                break;
185
+
186
+            default:                        /* on error, display message */
187
+                set_alert(status,response["message"]);
188
+                break;
189
+        }
190
+    });
191
+}

+ 2270
- 125
public_html/scripts/opaso.php
Разница между файлами не показана из-за своего большого размера
Просмотреть файл


+ 134
- 0
public_html/scripts/requests.js Просмотреть файл

@@ -0,0 +1,134 @@
1
+/*  Authors         :   Carlos C. Corrada-Bravo
2
+                        David J. Ortiz-Rivera
3
+
4
+    Organization    :   Centro de Desarrollo y Consultoria Computacional
5
+    Project         :   OPASO Material Registry   
6
+    File            :   requests.js
7
+    Description     :   Generate requests table */
8
+
9
+/* global values */
10
+var i;
11
+var person_id;
12
+var requested = {};
13
+next = 0;
14
+
15
+/* fetch requested materials */ 
16
+$(document).ready(fetch_requests);
17
+
18
+/* set_listeners() - listen for events */
19
+function set_listeners(){
20
+    /* confirm request */
21
+    $(".action").click(function(){
22
+        i = $(this).attr("value");
23
+        type = $(this).attr("id");
24
+
25
+        $.post("/scripts/opaso",{query: 30,type: type,material: JSON.stringify(requested[i])},function(data){
26
+            // console.log(data);
27
+            /* extract response */
28
+            let response = JSON.parse(data);
29
+            let status = response["status"];
30
+
31
+            /* handle by status */
32
+            switch(status){
33
+                case "expired":                  /* on expired, redirect to index */
34
+                    window.location.href = "/?error=session_expired";
35
+                    break;
36
+
37
+                case "success":                  /* on success, delete row */
38
+                    $(`#${i}`).remove();
39
+                    next -= 1;
40
+                    $(".table-total").text(`Total: ${next}`);
41
+
42
+                default:                        /* on success/error, display message */
43
+                    set_alert(status,response["message"]);
44
+                    break;
45
+            }
46
+        });
47
+
48
+    });
49
+}
50
+
51
+/* table_gen(data: dictionary) - generate table body */
52
+function table_gen(data){
53
+    for(var d in data){
54
+        let tr = element_gen("tr",{id: d});
55
+        let fs = data[d];
56
+        for(var f in fs){
57
+            switch(f){
58
+                case "person":                  /* extract id */
59
+                    var attrs = {person_id: fs[f]["person_id"],value: "person_name", text: fs[f]["person_name"]};
60
+                    break;
61
+
62
+                case "manufacturer":            /* extract id */
63
+                    var attrs = {man_id: fs[f]["man_id"],value: "man_name", text: fs[f]["man_name"]};
64
+                    break;
65
+
66
+                case "material":                /* extract id */
67
+                    var href = `/materials?mat_id=${fs[f]["mat_id"]}`;
68
+                    var link = element_gen("a",{class: "mat-link",text: fs[f]["mat_name"],target: "_blank",rel: "noopener noreferrer",href: href});
69
+                    var attrs = {value: "mat_name",childs: {link}};
70
+                    break;
71
+
72
+                case "prev_lab":                /* extract id */
73
+                case "new_lab":                 /* extract id */
74
+                    var href = `/laboratory?lab_id=${fs[f]["lab_id"]}`;
75
+                    var link = element_gen("a",{class: "lab-link",target: "_blank",rel: "noopener noreferrer",text: fs[f]["lab_room"],href: href});
76
+                    var attrs = {value: f,childs: {link}};
77
+                    break;
78
+                default:                        /* default */
79
+                    var attrs = {text: fs[f],value: f};
80
+                    break;
81
+            }
82
+            
83
+            var td = element_gen("td",attrs);
84
+            tr.append(td);
85
+        }
86
+
87
+        let ai =element_gen("i",{class: "request-icon material-icons", text: "check"});
88
+        let ri =element_gen("i",{class: "request-icon material-icons", text: "close"});
89
+        let ab = element_gen("button",{class: "action request",value: d,id: "accept",title: "request",childs: {ai}});
90
+        let rb = element_gen("button",{class: "action request",value: d,id: "reject",title: "request",childs: {ri}});
91
+        var td = element_gen("td",{value: "action",childs:{ab,rb}});
92
+        tr.append(td);
93
+        $("tbody").append(tr);
94
+    }
95
+
96
+    $(".processing").hide();
97
+    setTimeout(function(){
98
+        set_listeners();
99
+        $(".main-wrapper").show();
100
+    },250);
101
+}
102
+
103
+
104
+/* fetch_requests() - fetch material requests */
105
+function fetch_requests(){
106
+    $.post("/scripts/opaso",{query: 29},function(data){
107
+        // console.log(data);
108
+        /* extract response */
109
+        let response = JSON.parse(data);
110
+        let status = response["status"];
111
+
112
+        /* handle by status */
113
+        switch(status){
114
+            case "success":                 /* on success, generate table */
115
+                var date = new Date();
116
+                date = date.toString().split(" ").splice(1,4).join(" ");
117
+                $(".sub-header").text(`As of: ${date}`);
118
+
119
+                requested = response["requested"];
120
+                next = Object.keys(requested).length;
121
+                $(".table-total").text(`Total: ${next}`);
122
+                table_gen(requested);
123
+                break;
124
+
125
+            case "expired":                  /* on expired, redirect to index */
126
+                window.location.href = "/?error=session_expired";
127
+                break;
128
+
129
+            default:                        /* on error, display message */
130
+                set_alert(status,response["message"]);
131
+                break;
132
+        }
133
+    });
134
+}

+ 81
- 0
public_html/scripts/transactions.js Просмотреть файл

@@ -0,0 +1,81 @@
1
+/*  Authors         :   Carlos C. Corrada-Bravo
2
+                        David J. Ortiz-Rivera
3
+
4
+    Organization    :   Centro de Desarrollo y Consultoria Computacional
5
+    Project         :   OPASO Material Registry   
6
+    File            :   transactions.js
7
+    Description     :   Generate transactions table */
8
+
9
+/* total transactions */
10
+var next = 0;
11
+
12
+/* fetch transactions */ 
13
+$(document).ready(fetch_transactions);
14
+
15
+/* table_gen(transactions: dictionary) - generate and append table row(s) */
16
+function table_gen(transactions){
17
+    /* generate rows */
18
+    for(var key in transactions){
19
+        let tr = element_gen("tr",{class: "transaction-row",id: key});
20
+        let fields = transactions[key];
21
+        for(var field in fields){
22
+            switch(field){
23
+            case "material":                 /* generate material link */
24
+                var href = `/materials?mat_id=${fields[field]["mat_id"]}`;
25
+                var link = element_gen("a",{class: "mat-link",text: fields[field]["mat_name"],href: href,target: "_blank",rel: "noopener noreferrer"});
26
+                var cell = element_gen("td",{class: "transaction-cell",value: "mat_name",childs: {link}});
27
+                break;
28
+            
29
+            case "lab":                 /* generate lab link */
30
+                var href = `/laboratory?lab_id=${fields[field]["lab_id"]}`;
31
+                var link = element_gen("a",{class: "lab-link",text: fields[field]["lab_room"],href: href,target: "_blank",rel: "noopener noreferrer"});
32
+                var cell = element_gen("td",{class: "transaction-cell",value: "lab_room",childs: {link}});
33
+                break;
34
+
35
+            default:                        /* default */
36
+                var cell = element_gen("td",{class: "transaction-cell",text: fields[field],value: field});
37
+                break;
38
+
39
+            }
40
+
41
+            tr.append(cell);
42
+        }
43
+
44
+        $("tbody").append(tr);
45
+    }
46
+
47
+    $(".processing").hide();
48
+    setTimeout(function(){
49
+        $(".main-wrapper").show();
50
+    },250);
51
+}
52
+
53
+/* fetch_transactions() - fetch transactions */ 
54
+function fetch_transactions(){
55
+    $.post("/scripts/opaso",{query: 22},function(data){
56
+        console.log(data);
57
+        /* extract response */
58
+        let response = JSON.parse(data);
59
+        let status = response["status"];
60
+
61
+        /* handle by status */
62
+        switch(status){
63
+            case "success":                 /* on success, generate table */
64
+                var date = new Date();
65
+                date = date.toString().split(" ").splice(1,4).join(" ");
66
+                $(".sub-header").text(`As of: ${date}`);
67
+                next = Object.keys(response["transactions"]).length;
68
+                $(".table-total").text(`Total: ${next}`);
69
+                table_gen(response["transactions"]);
70
+                break;
71
+            
72
+            case "expired":                 /* on expired, redirect to index */
73
+                window.location.href = "/?error=session_expired";
74
+                break;
75
+
76
+            default:                        /* on error, display message */
77
+                set_alert(status,response["message"]);
78
+                break;
79
+        }
80
+    });
81
+}