Add more fields, add create capability
This commit is contained in:
parent
83cf691a96
commit
190cd221a9
@ -7,18 +7,18 @@ $from = $_GET['from'];
|
|||||||
require 'readfrom.php';
|
require 'readfrom.php';
|
||||||
|
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
if (is_empty($id)) {
|
if (is_empty($id) || $id == 0 || $id == null) {
|
||||||
sendError('Missing item ID!');
|
$loc = '0';
|
||||||
}
|
|
||||||
$loc;
|
|
||||||
if ($from == 'assets') {
|
|
||||||
$loc = $database->select($from, 'rtd_location_id', ['id' => $id])[0];
|
|
||||||
} else {
|
} else {
|
||||||
$loc = $database->select($from, 'location_id', ['id' => $id])[0];
|
if ($from == 'assets') {
|
||||||
}
|
$loc = $database->select($from, 'rtd_location_id', ['id' => $id])[0];
|
||||||
|
} else {
|
||||||
|
$loc = $database->select($from, 'location_id', ['id' => $id])[0];
|
||||||
|
}
|
||||||
|
|
||||||
if ($loc == null) {
|
if ($loc == null) {
|
||||||
$loc = 0;
|
$loc = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $database->select('locations', ['id', 'name']);
|
$list = $database->select('locations', ['id', 'name']);
|
||||||
|
26
getmodel.php
Normal file
26
getmodel.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require 'required.php';
|
||||||
|
//require 'dieifnotloggedin.php';
|
||||||
|
|
||||||
|
$from = $_GET['from'];
|
||||||
|
require 'readfrom.php';
|
||||||
|
|
||||||
|
$id = $_GET['id'];
|
||||||
|
if (is_empty($id) || $id == 0 || $id == null) {
|
||||||
|
$model = '0';
|
||||||
|
} else {
|
||||||
|
if ($from == 'assets') {
|
||||||
|
$model = $database->select($from, 'model_id', ['id' => $id])[0];
|
||||||
|
} else {
|
||||||
|
sendError("Command only valid for assets.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model == null) {
|
||||||
|
$model = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$list = $database->select('models', ['id', 'name']);
|
||||||
|
|
||||||
|
die(json_encode(['status' => 'OK', 'model' => $model, 'list' => $list]));
|
@ -7,18 +7,18 @@ $from = $_GET['from'];
|
|||||||
require 'readfrom.php';
|
require 'readfrom.php';
|
||||||
|
|
||||||
$id = $_GET['id'];
|
$id = $_GET['id'];
|
||||||
if (is_empty($id)) {
|
if (is_empty($id) || $id == 0 || $id == null) {
|
||||||
sendError('Missing item ID!');
|
$status = '0';
|
||||||
}
|
|
||||||
$status;
|
|
||||||
if ($from == 'assets') {
|
|
||||||
$status = $database->select($from, 'status_id', ['id' => $id])[0];
|
|
||||||
} else {
|
} else {
|
||||||
sendError("Command only valid for assets.");
|
if ($from == 'assets') {
|
||||||
}
|
$status = $database->select($from, 'status_id', ['id' => $id])[0];
|
||||||
|
} else {
|
||||||
|
sendError("Command only valid for assets.");
|
||||||
|
}
|
||||||
|
|
||||||
if ($status == null) {
|
if ($status == null) {
|
||||||
$status = 0;
|
$status = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $database->select('status_labels', ['id', 'name', 'notes']);
|
$list = $database->select('status_labels', ['id', 'name', 'notes']);
|
||||||
|
11
required.php
11
required.php
@ -39,11 +39,12 @@ function authenticate_user($username, $password) {
|
|||||||
global $database;
|
global $database;
|
||||||
$qf = 'username';
|
$qf = 'username';
|
||||||
if (!username_exists($username)) {
|
if (!username_exists($username)) {
|
||||||
if (!email_exists($username)) {
|
// if (!email_exists($username)) {
|
||||||
return false;
|
// return false;
|
||||||
} else {
|
// } else {
|
||||||
$qf = 'email';
|
// $qf = 'email';
|
||||||
}
|
// }
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
$hash = $database->select('users', ['password'], [$qf => $username])[0]['password'];
|
$hash = $database->select('users', ['password'], [$qf => $username])[0]['password'];
|
||||||
return (password_verify($password, $hash));
|
return (password_verify($password, $hash));
|
||||||
|
@ -7,13 +7,23 @@ $from = $_POST['from'];
|
|||||||
require 'readfrom.php';
|
require 'readfrom.php';
|
||||||
|
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
if (is_empty($id)) {
|
if (is_empty($_POST['asset_tag'])) {
|
||||||
sendError('Missing item ID!');
|
sendError('Please fill in an asset tag.');
|
||||||
}
|
|
||||||
if ($from == 'assets') {
|
|
||||||
$database->update($from, ['name' => $_POST['name'], 'rtd_location_id' => $_POST['location'], 'order_number' => $_POST['order_number'], 'status_id' => $_POST['status']], ['id' => $id]);
|
|
||||||
} else {
|
|
||||||
$database->update($from, ['name' => $_POST['name'], 'location_id' => $_POST['location'], 'qty' => $_POST['qty'], 'order_number' => $_POST['order_number']], ['id' => $id]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_empty($id)) {
|
||||||
|
if ($from == 'assets') {
|
||||||
|
$user_id = $database->select('users', 'id', ['username' => $_SESSION['user']])[0];
|
||||||
|
$database->insert($from, ['name' => $_POST['name'], 'user_id' => $user_id, 'asset_tag' => $_POST['asset_tag'], 'rtd_location_id' => $_POST['location'], 'order_number' => $_POST['order_number'], 'status_id' => $_POST['status'], 'serial' => $_POST['serial'], 'model_id' => $_POST['model'], '#updated_at' => 'NOW()', '#created_at' => 'NOW()', '_snipeit_hard_drive_secure__y_n_' => $_POST['hdd_secure']]);
|
||||||
|
} else {
|
||||||
|
$database->insert($from, ['name' => $_POST['name'], 'location_id' => $_POST['location'], 'qty' => $_POST['qty'], 'order_number' => $_POST['order_number'], '#updated_at' => 'NOW()', '#created_at' => 'NOW()']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if ($from == 'assets') {
|
||||||
|
$database->update($from, ['name' => $_POST['name'], 'asset_tag' => $_POST['asset_tag'], 'rtd_location_id' => $_POST['location'], 'order_number' => $_POST['order_number'], 'status_id' => $_POST['status'], 'serial' => $_POST['serial'], 'model_id' => $_POST['model'], '#updated_at' => 'NOW()', '_snipeit_hard_drive_secure__y_n_' => $_POST['hdd_secure']], ['id' => $id]);
|
||||||
|
} else {
|
||||||
|
$database->update($from, ['name' => $_POST['name'], 'location_id' => $_POST['location'], 'qty' => $_POST['qty'], 'order_number' => $_POST['order_number'], '#updated_at' => 'NOW()'], ['id' => $id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
sendOK();
|
sendOK();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user