mirror of
https://github.com/itflow-org/itflow
synced 2026-03-05 21:34:51 +00:00
Add functionality to for adding new assets via API
This commit is contained in:
@@ -109,7 +109,9 @@
|
|||||||
* XML Phonebook Download - /api.php?api_key=[API_KEY]&phonebook
|
* XML Phonebook Download - /api.php?api_key=[API_KEY]&phonebook
|
||||||
* Client Email (great for mailing lists) - /api.php?api_key=[API_KEY]&client_emails - Returns Client Name - Email Address
|
* Client Email (great for mailing lists) - /api.php?api_key=[API_KEY]&client_emails - Returns Client Name - Email Address
|
||||||
* Account Balance for Client (can be integrated into multiple places for example in FreePBX Press 3 to check account balance, please enter your client ID your balance is) - /api.php?api_key=[API_KEY]&client_id=[CLIENT_ID] - Returns Account Balance
|
* Account Balance for Client (can be integrated into multiple places for example in FreePBX Press 3 to check account balance, please enter your client ID your balance is) - /api.php?api_key=[API_KEY]&client_id=[CLIENT_ID] - Returns Account Balance
|
||||||
NOTE: [API_KEY] - is auto generated when a company is created and shows up in General Settings, this can also be changed manually.
|
* Add new asset for a client - /api.php?api_key=[API_KEY]&add_asset=Name&type=[Desktop|Laptop|Server]&make=Make&model=Model&serial=Serial&os=OS
|
||||||
|
* Required: api_key, add_asset (name)
|
||||||
|
* NOTE: [API_KEY] - is auto generated when a company is created and shows up in General Settings, this can also be changed manually.
|
||||||
|
|
||||||
### Future Todo
|
### Future Todo
|
||||||
* MeshCentral / TacticalRMM (Export Assets Info to ITFlow, Exports common software applications to Software)
|
* MeshCentral / TacticalRMM (Export Assets Info to ITFlow, Exports common software applications to Software)
|
||||||
|
|||||||
21
api.php
21
api.php
@@ -1,8 +1,6 @@
|
|||||||
<?php include("config.php"); ?>
|
<?php include("config.php"); ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
//Check Key
|
|
||||||
|
|
||||||
|
|
||||||
// Check API key is provided in GET request as 'api_key'
|
// Check API key is provided in GET request as 'api_key'
|
||||||
if(!isset($_GET['api_key']) OR empty($_GET['api_key'])) {
|
if(!isset($_GET['api_key']) OR empty($_GET['api_key'])) {
|
||||||
@@ -41,7 +39,7 @@ if(isset($_GET['cid'])){
|
|||||||
$name = $row['name'];
|
$name = $row['name'];
|
||||||
|
|
||||||
echo "$name - $cid";
|
echo "$name - $cid";
|
||||||
//Alert whern call comes through
|
//Alert when call comes through
|
||||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Inbound Call', alert_message = 'Inbound call from $name - $cid', alert_date = NOW(), company_id = $company_id");
|
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Inbound Call', alert_message = 'Inbound call from $name - $cid', alert_date = NOW(), company_id = $company_id");
|
||||||
//Log When call comes through
|
//Log When call comes through
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Call', log_action = 'Inbound', log_description = 'Inbound call from $name - $cid', log_created_at = NOW(), company_id = $company_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Call', log_action = 'Inbound', log_description = 'Inbound call from $name - $cid', log_created_at = NOW(), company_id = $company_id");
|
||||||
@@ -185,7 +183,24 @@ if(isset($_GET['account_balance'])){
|
|||||||
//Log
|
//Log
|
||||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Account Balance', log_description = 'Client $client_id checked their balance which had a balance of $balance', log_created_at = NOW(), company_id = $company_id");
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Account Balance', log_description = 'Client $client_id checked their balance which had a balance of $balance', log_created_at = NOW(), company_id = $company_id");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET['add_asset']) && isset($_GET['client_id'])) {
|
||||||
|
$client_id = intval($_GET['client_id']);
|
||||||
|
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['add_asset'])));
|
||||||
|
$type = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['type'])));
|
||||||
|
$make = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['make'])));
|
||||||
|
$model = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['model'])));
|
||||||
|
$serial = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['serial'])));
|
||||||
|
$os = trim(strip_tags(mysqli_real_escape_string($mysqli,$_GET['os'])));
|
||||||
|
|
||||||
|
// Add
|
||||||
|
mysqli_query($mysqli,"INSERT INTO assets SET asset_name = '$name', asset_type = '$type', asset_make = '$make', asset_model = '$model', asset_serial = '$serial', asset_os = '$os', asset_created_at = NOW(), asset_client_id = $client_id, company_id = $company_id");
|
||||||
|
|
||||||
|
//Logging
|
||||||
|
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'API', log_action = 'Asset Created', log_description = '$name', log_created_at = NOW(), company_id = $company_id");
|
||||||
|
|
||||||
|
echo "Asset added!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user