Pārlūkot izejas kodu

Upload files to 'public_html'

david.ortiz11 5 gadus atpakaļ
vecāks
revīzija
e5ec48fdc8
4 mainītis faili ar 457 papildinājumiem un 0 dzēšanām
  1. 122
    0
      public_html/offered.php
  2. 100
    0
      public_html/requests.php
  3. 129
    0
      public_html/session.php
  4. 106
    0
      public_html/transactions.php

+ 122
- 0
public_html/offered.php Parādīt failu

@@ -0,0 +1,122 @@
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
7
+        Description     :   Display offered materials -->
8
+
9
+<!-- verify session -->
10
+<?php require_once("header.php");?>
11
+
12
+<!doctype html>
13
+<html lang="en">
14
+    <!-- encoding/imports/styling -->
15
+    <head>
16
+        <meta charset="utf-8">
17
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
+        <title class="title">Offered Materials</title>
19
+        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
20
+        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
21
+        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
22
+        <link rel="stylesheet" href="/style/main.css">
23
+        <link rel="stylesheet" href="/style/offered.css">
24
+    </head>
25
+
26
+    <!-- content -->
27
+    <body>
28
+        <!-- form-->
29
+        <div class="form-shader close-form">
30
+            <div class="lab-form close-form">
31
+                <div class="form-wrapper">
32
+                    <div class="form-header-wrapper">
33
+                        <h5 class="form-header main-header">Request Material</h5>
34
+                        <div class="close-icon"><i class="close-form material-icons">close</i></div>
35
+                    </div>
36
+                    <div class="form">
37
+                        <div class="form-body">
38
+                            <span class="form-message"></span>
39
+                            <div class="select-wrapper">
40
+                                <label class="select-label" for="number">Laboratory: </label>
41
+                                <select class="labs"></select>
42
+                            </div>
43
+                        </div>
44
+                        <div class="form-actions">
45
+                            <button class="btn btn-primary action-btn submit" id="main-submit">Submit</button>
46
+                        </div>
47
+                    </div>
48
+                </div>
49
+            </div>
50
+        </div>
51
+
52
+        <!-- alerts -->
53
+        <div class="alerts">
54
+            <div class="alert">
55
+                <div class="message-icon-wrapper">
56
+                    <i class="message-icon success-icon material-icons">done</i>
57
+                    <i class="message-icon error-icon failed-icon warning-icon material-icons">close</i>
58
+                </div>
59
+                <p class="alert-status"></p>
60
+                <p class="alert-message"></p>
61
+            </div>
62
+        </div>
63
+
64
+        <div class="content">
65
+            <!-- navbar -->
66
+            <?php require_once("navbar.php")?>
67
+            <div class="main">
68
+                <div class="header-wrapper">
69
+                    <h5 class="header">Offered Materials</h5>
70
+                    
71
+                    <!-- processing -->
72
+                    <div class="processing">
73
+                        <p class="processing-text">Fetching materials...</p>
74
+                        <div class="loader"></div>
75
+                    </div>
76
+                </div>
77
+
78
+                <div class="main-wrapper">
79
+                    <div class="float-right">
80
+                        <div class="search-form-wrapper">
81
+                            <input class="search-form" placeholder="Search for materials" type="text" name="search-form">
82
+                            <button class="clear-btn search-form-submit">
83
+                                <i class="material-icons clear-icon">close</i>
84
+                            </button>
85
+                        </div>
86
+                    </div>
87
+
88
+                    <!-- materials -->
89
+                    <h6 class="header sub-header"></h6>
90
+                    <div class="table-wrapper content-wrapper">
91
+                        <table class="table">
92
+                            <thead class="table-header">
93
+                                <tr>
94
+                                    <th value="mat_name">Material</th>
95
+                                    <th value="date">Date</th>
96
+                                    <th value="man_name">Manufacturer</th>
97
+                                    <th value="capacity">Capacity</th>
98
+                                    <th value="amount">Amount</th>
99
+                                    <th value="person_name">Person</th>
100
+                                    <th value="lab_room">Lab</th>
101
+                                    <th value="actions">Request</th>
102
+                                </tr>
103
+                            </thead>
104
+                            <tbody></tbody>
105
+                        </table>
106
+                    </div>
107
+                    <h6 class="header table-total"></h6>
108
+                </div>
109
+            </div>
110
+
111
+            <!-- footer -->
112
+            <?php require_once("footer.php")?>
113
+        </div>  
114
+
115
+        <!-- scripts -->
116
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
117
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
118
+        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
119
+        <script type="text/javascript" src="/scripts/main.js"></script>
120
+        <script type="text/javascript" src="/scripts/offered.js"></script>
121
+    </body>
122
+</html>

+ 100
- 0
public_html/requests.php Parādīt failu

@@ -0,0 +1,100 @@
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
7
+        Description     :   Display material requests -->
8
+
9
+<!-- verify session -->
10
+<?php require_once("header.php");?>
11
+
12
+<!doctype html>
13
+<html lang="en">
14
+    <!-- encoding/imports/styling -->
15
+    <head>
16
+        <meta charset="utf-8">
17
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
18
+        <title class="title">Material Requests</title>
19
+        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
20
+        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
21
+        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
22
+        <link rel="stylesheet" href="/style/main.css">
23
+        <link rel="stylesheet" href="/style/offered.css">
24
+    </head>
25
+
26
+    <!-- content -->
27
+    <body>
28
+        <!-- alerts -->
29
+        <div class="alerts">
30
+            <div class="alert">
31
+                <div class="message-icon-wrapper">
32
+                    <i class="message-icon success-icon material-icons">done</i>
33
+                    <i class="message-icon error-icon failed-icon warning-icon material-icons">close</i>
34
+                </div>
35
+                <p class="alert-status"></p>
36
+                <p class="alert-message"></p>
37
+            </div>
38
+        </div>
39
+
40
+        <div class="content">
41
+            <!-- navbar -->
42
+            <?php require_once("navbar.php")?>
43
+            <div class="main">
44
+                <div class="header-wrapper">
45
+                    <h5 class="header">Material Requests</h5>
46
+                    
47
+                    <!-- processing -->
48
+                    <div class="processing">
49
+                        <p class="processing-text">Fetching requests...</p>
50
+                        <div class="loader"></div>
51
+                    </div>
52
+                </div>
53
+
54
+                <div class="main-wrapper">
55
+                    <!-- search form -->
56
+                    <div class="float-right">
57
+                        <div class="search-form-wrapper">
58
+                            <input class="search-form" placeholder="Search for requests" type="text" name="search-form">
59
+                            <button class="clear-btn search-form-submit">
60
+                                <i class="material-icons clear-icon">close</i>
61
+                            </button>
62
+                        </div>
63
+                    </div>
64
+
65
+                    <!-- requests -->
66
+                    <h6 class="header sub-header"></h6>
67
+                    <div class="table-wrapper content-wrapper">
68
+                        <table class="table">
69
+                            <thead class="table-header">
70
+                                <tr>
71
+                                    <th value="mat_name">Material</th>
72
+                                    <th value="man_name">Manufacturer</th>
73
+                                    <th value="capacity">Capacity</th>
74
+                                    <th value="amount">Amount</th>
75
+                                    <th value="person_name">Requestor</th>
76
+                                    <th value="lab_room">Previous Lab</th>
77
+                                    <th value="lab_room">New Lab</th>
78
+                                    <th value="actions">Actions</th>
79
+                                </tr>
80
+                            </thead>
81
+                            <tbody></tbody>
82
+                        </table>
83
+                    </div>
84
+
85
+                    <h6 class="header table-total"></h6>
86
+                </div>
87
+            </div>
88
+
89
+            <!-- footer -->
90
+            <?php require_once("footer.php")?>
91
+        </div>  
92
+
93
+        <!-- scripts -->
94
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
95
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
96
+        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
97
+        <script type="text/javascript" src="/scripts/main.js"></script>
98
+        <script type="text/javascript" src="/scripts/requests.js"></script>
99
+    </body>
100
+</html>

+ 129
- 0
public_html/session.php Parādīt failu

@@ -0,0 +1,129 @@
1
+<?php
2
+/*  Authors         :   Carlos C. Corrada-Bravo
3
+                        David J. Ortiz-Rivera
4
+
5
+    Organization    :   Centro de Desarrollo y Consultoria Computacional
6
+    Project         :   OPASO Material Registry   
7
+    File            :   session.php
8
+    Description     :   Handle google login for OPASO */
9
+
10
+	/* verify token */
11
+	if(isset($_GET["code"])){
12
+    	/* initialize client */
13
+		require_once "vendor/autoload.php";
14
+		$config = "config/o_auth.json";
15
+    	$client = new Google_Client();
16
+    	$client->setAuthConfig($config);
17
+		
18
+		/* fetch token */
19
+		$token = $client->fetchAccessTokenWithAuthCode($_GET["code"]);
20
+
21
+		/* handle expired token */
22
+		if(isset($token["error"])){	
23
+			header("Location: /?error=token_expired");
24
+			die();
25
+		}
26
+
27
+		/* verify login */
28
+		else{
29
+			/* extract user email */
30
+			require "config/database.php";
31
+			$client->setAccessToken($token["access_token"]);
32
+			$google_oauth = new Google_Service_Oauth2($client);
33
+			$account_info = $google_oauth->userinfo->get();
34
+			$email = $account_info->email;
35
+
36
+			/* fetch user data */
37
+			$sign_in = $db->prepare("SELECT person_id,person_name FROM Person WHERE email=?");
38
+			$sign_in->bind_param("s",$email);
39
+			$sign_in->execute();
40
+			$sign_in->bind_result($person_id,$person_name);
41
+			$sign_in->store_result();
42
+
43
+			/* registered email */
44
+			if($sign_in->fetch()){
45
+				$authorized = $db->prepare("SELECT Authorized.lab_id,Laboratory.lab_room,Authorized.access_level FROM Authorized INNER JOIN Laboratory ON Laboratory.lab_id = Authorized.lab_id WHERE person_id=? AND Authorized.access_level!='none' ORDER BY Laboratory.lab_room ASC");
46
+
47
+				$authorized->bind_param("i",$person_id);
48
+				$authorized->execute();
49
+				$authorized->bind_result($lab_id,$lab_room,$access_level);
50
+				$authorized->store_result();
51
+				/* start user session */
52
+				start_session();
53
+
54
+				$_SESSION["authorized"] = array();
55
+				$access_level = "technician";
56
+				$pi_flag = false;
57
+				$admin_flag = false;
58
+
59
+				/* fetch entries */
60
+				while($authorized->fetch()){
61
+					if($access_level == "investigator"){
62
+						$pi_flag = true;
63
+					}
64
+
65
+					elseif($access_level == "admin"){
66
+						$admin_flag = true;
67
+					}
68
+
69
+			    	$_SESSION["authorized"][$lab_id] = array("lab_room" => $lab_room, "access_level" => $access_level);
70
+				}
71
+
72
+				/* set user data */
73
+				$_SESSION["person_id"] = $person_id;
74
+				$_SESSION["person_name"] = explode(" ",$person_name)[0];
75
+
76
+				/* set highest access level */
77
+				if($pi_flag){
78
+					$access_level = "investigator";
79
+				}
80
+
81
+				elseif($admin_flag){
82
+					$access_level = "admin";
83
+				}
84
+
85
+				$_SESSION["access_level"] = $access_level;
86
+    			$_SESSION["created"] = time();
87
+				$_SESSION["last_activity"] = time();
88
+
89
+				/* save lab data */
90
+				while($authorized->fetch()){
91
+			    	$_SESSION["authorized"][$lab_id] = array("lab_room" => $lab_room, "access_level" => $access_level);
92
+				}
93
+
94
+				/* set user data */
95
+				$_SESSION["person_id"] = $person_id;
96
+				$_SESSION["person_name"] = explode(" ",$person_name)[0];
97
+    			$_SESSION["created"] = time();
98
+				$_SESSION["last_activity"] = time();
99
+				
100
+				$sign_in->close();
101
+				$authorized->close();
102
+				header("Location: menu");
103
+				exit();
104
+			}
105
+
106
+			/* unregistered email */ 
107
+			else{
108
+				header("Location: /?error=login_failed");
109
+				die();
110
+			}
111
+				
112
+			$sign_in->close();
113
+		}
114
+	}
115
+
116
+	/* redirect to index */
117
+	else{
118
+		header("Location: /");
119
+		die();
120
+	}
121
+
122
+	/* start session */
123
+	function start_session(){
124
+		/* start user session */
125
+		if(!isset($_SESSION)){
126
+			session_start();
127
+	    }
128
+	}
129
+?>

+ 106
- 0
public_html/transactions.php Parādīt failu

@@ -0,0 +1,106 @@
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
7
+        Description     :   Display transactions -->
8
+
9
+<!-- verify session -->
10
+<?php require_once("header.php");
11
+
12
+    /* start user session */
13
+    if(!isset($_SESSION)){
14
+        session_start();
15
+    }
16
+    if(!($_SESSION["access_level"] === "admin") and !($_SESSION["access_level"] === "investigator")){
17
+        header("Location: /menu");
18
+        die();
19
+    }
20
+?>
21
+
22
+<!doctype html>
23
+<html lang="en">
24
+    <!-- encoding/imports/styling -->
25
+    <head>
26
+        <meta charset="utf-8">
27
+        <meta name="viewport" content="width=device-width, initial-scale=1.0">
28
+        <title class="title">Transactions</title>
29
+        <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
30
+        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
31
+        <link rel="stylesheet" href="/style/main.css">
32
+    </head>
33
+
34
+    <!-- content -->
35
+    <body>
36
+        <!-- alerts -->
37
+        <div class="alerts">
38
+            <div class="alert">
39
+                <div class="message-icon-wrapper">
40
+                    <i class="message-icon success-icon material-icons">done</i>
41
+                    <i class="message-icon error-icon failed-icon warning-icon material-icons">close</i>
42
+                </div>
43
+                <p class="alert-status"></p>
44
+                <p class="alert-message"></p>
45
+            </div>
46
+        </div>
47
+
48
+        <div class="content">
49
+            <!-- navbar -->
50
+            <?php require_once("navbar.php")?>
51
+            <div class="main">
52
+                <div class="header-wrapper">
53
+                    <h5 class="header">Transactions</h5>
54
+                    
55
+                    <!-- processing -->
56
+                    <div class="processing">
57
+                        <p class="processing-text">Fetching transactions...</p>
58
+                        <div class="loader"></div>
59
+                    </div>
60
+                </div>
61
+
62
+                <div class="main-wrapper">
63
+                    <div class="float-right">
64
+                        <div class="search-form-wrapper">
65
+                            <input class="search-form" placeholder="Search for transactions" type="text" name="search-form">
66
+                            <button class="clear-btn search-form-submit">
67
+                                <i class="material-icons clear-icon">close</i>
68
+                            </button>
69
+                        </div>
70
+                    </div>
71
+
72
+                    <!-- transaction -->
73
+                    <h6 class="header sub-header"></h6>
74
+                    <div class="table-wrapper content-wrapper">
75
+                        <table class="table">
76
+                            <thead class="table-header">
77
+                                <tr>
78
+                                    <th class="sort" value="mat_name" >Type</th>
79
+                                    <th  class="sort" value="man_name">Person</th>
80
+                                    <th value="">Date</th>
81
+                                    <th value="">Material</th>
82
+                                    <th value="">Manufacturer</th>
83
+                                    <th >Lab</th>
84
+                                    <th value="uom">Capacity</th>
85
+                                    <th >Amount</th>
86
+                                </tr>
87
+                            </thead>
88
+                            <tbody></tbody>
89
+                        </table>
90
+                    </div>
91
+                    <h6 class="header table-total"></h6>
92
+                </div>
93
+            </div>
94
+
95
+            <!-- footer -->
96
+            <?php require_once("footer.php")?>
97
+        </div>  
98
+
99
+        <!-- scripts -->
100
+        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
101
+        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
102
+        <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
103
+        <script type="text/javascript" src="/scripts/main.js"></script>
104
+        <script type="text/javascript" src="/scripts/transactions.js"></script>
105
+    </body>
106
+</html>