diff --git a/app.py b/app.py
index 4289658..6f3735d 100644
--- a/app.py
+++ b/app.py
@@ -5,11 +5,52 @@ app = Flask(__name__)
connection = sql_utils.connect_database('ubuntu-mariadb.home','admin','password','inventory')
+
+@app.route('/user_search')
+def user_search():
+ data = request.args.get('data')
+ query = f'''
+SELECT u.name,u.id_num,u.assigned_asset,u.assigned_card
+FROM users u
+WHERE u.name like '%{data.upper()}%\''''
+ response = sql_utils.read_query(connection, query)
+ print(response)
+ return response
+
+@app.route('/asset_tag_search')
+def asset_tag_search():
+ data = request.args.get('data')
+ query = f'''SELECT a.asset_id, a.serial, a.model, a.category, u.name
+FROM assets a
+left JOIN users u ON u.assigned_asset=a.asset_id
+WHERE a.asset_id = {data.upper()}'''
+ response = sql_utils.read_query(connection, query)
+ return response
+
+@app.route('/serial_search')
+def serial_search():
+ data = request.args.get('data')
+ query = f'''SELECT a.asset_id, a.serial, a.model, a.category, u.name
+FROM assets a
+left JOIN users u ON u.assigned_asset=a.asset_id
+WHERE a.serial LIKE "{data.upper()}"'''
+ response = sql_utils.read_query(connection, query)
+ return response
+
@app.route('/asset_list')
def asset_list():
- data = sql_utils.read_query(connection,'select * from assets;')
+ query = '''
+select a.asset_id,a.serial,a.model,a.category,u.name
+from assets a
+left join users u on u.assigned_asset=a.asset_id
+'''
+ data = sql_utils.read_query(connection,query)
return data
+@app.route('/add')
+def add_data():
+ return render_template('adding.html')
+
@app.route("/")
def default():
return render_template('main.html')
diff --git a/generate_data.py b/generate_data.py
index 4e9b39d..b4548e9 100644
--- a/generate_data.py
+++ b/generate_data.py
@@ -9,4 +9,6 @@ for i in range(0,100):
serial = "".join(random.choices(alphabet, k=12))
query = f'insert into assets (serial) values ("{serial}")'
sql_utils.send_query(connection, query)
- print(f'Inserting: {serial}')
\ No newline at end of file
+ print(f'Inserting: {serial}')
+
+print("test")
\ No newline at end of file
diff --git a/templates/add.js b/templates/add.js
new file mode 100644
index 0000000..e24b816
--- /dev/null
+++ b/templates/add.js
@@ -0,0 +1,3 @@
+function update_add_asset_model() {
+
+}
\ No newline at end of file
diff --git a/templates/adding.html b/templates/adding.html
new file mode 100644
index 0000000..5ef137d
--- /dev/null
+++ b/templates/adding.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+ Adding
+
+
+
+
+
+
+
Add asset
+
+
+
+
Add user
+
+
+
Add access card
+
+
+
Modify asset
+
+
+
Modify user
+
+
+
Modify access card
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/templates/main.html b/templates/main.html
index a1fbc4f..b291dc9 100644
--- a/templates/main.html
+++ b/templates/main.html
@@ -4,36 +4,133 @@
- Document
+ Searching
- Assets
-
-
- | Asset tag |
- Serial Number |
- Model |
- Category |
-
-
-
+
+
Assets
+
+
+ | Asset tag |
+ Serial Number |
+ Model |
+ Category |
+ Assigned to |
+
+
+
+
+
User info search
+
+
+
+
+
results
+
+
+ | Name |
+ ID number |
+ Assigned asset |
+ Assigned card |
+
+
+
+
+
Asset number search
+
+
+
+
+
results
+
+
use the search box above to get results
+
+
+
+