-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benoit DANGUY
committed
Apr 25, 2022
1 parent
4549942
commit d047df1
Showing
2,904 changed files
with
291,665 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# GLPI_physical_inventory | ||
Inventaire physique via lecture de QR Code sur smartphone. | ||
|
||
Cet outil utilise l'API REST de GLPI pour mettre à jour les équipements présents dans GLPI. | ||
Pour cela, vous devez utiliser le plugin Barcode pour générer des QR Code pour vos équipements. Les QR Codes doivent contenir à minima les informations suivantes lors de la génération : ID, Nom, NOM, Web page of the device, Web page of the item | ||
|
||
# Installation | ||
Il suffit de déposer les fichiers sur un serveur web accessible depuis votre smartphone. | ||
Ensuite, il faut modifier le fichier config/config.php afin de renseigner les information de votre instance GLPI |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
require "../config/config.php"; | ||
require "../inc/utils.php"; | ||
require "../inc/vendor/autoload.php"; | ||
|
||
setlocale(LC_TIME, 'fr_FR'); | ||
date_default_timezone_set('Europe/Paris'); | ||
|
||
|
||
// Instanciate the API client | ||
$client = new Glpi\Api\Rest\Client(URL_GLPI.'/apirest.php/', new GuzzleHttp\Client()); | ||
|
||
// Authenticate | ||
try { | ||
|
||
$client->setAppToken(GLPI_APPTOKEN); | ||
$client->initSessionByCredentials(GLPI_USER, GLPI_PASS); | ||
|
||
} catch (Exception $e) { | ||
echo $e->getMessage(); | ||
die(); | ||
} | ||
$itemHandler = new \Glpi\Api\Rest\ItemHandler($client); | ||
|
||
|
||
//Mise à jour du matériel | ||
$datas= array( | ||
"users_id" => $_POST["users_id"], | ||
"locations_id" => $_POST["locations_id"], | ||
"states_id" => $_POST["states_id"] | ||
); | ||
|
||
$response = $itemHandler->updateItems($_POST["type"],$_POST["id"],$datas); | ||
|
||
|
||
//Mise à jour infos de gestion (date d'inventaire physique) | ||
|
||
//Récup infocoms | ||
$response = $itemHandler->getSubItems($_POST["type"],$_POST["id"], "Infocom"); | ||
$item = json_decode($response['body']); | ||
|
||
if(!empty($item)) | ||
{ | ||
//si infocoms actives | ||
$datas= array( | ||
"inventory_date" => date('Y-m-d H:i:s') | ||
); | ||
$response = $itemHandler->updateItems("Infocom",$item[0]->id,$datas); | ||
} | ||
else | ||
{ | ||
//si infocoms pas actives | ||
$datas= array( | ||
"items_id" => $_POST["id"], | ||
"itemtype" => $_POST["type"], | ||
"entities_id" => 1, | ||
"inventory_date" => date('Y-m-d H:i:s') | ||
); | ||
$response = $itemHandler->addItems("Infocom",$datas); | ||
} | ||
?> |
Oops, something went wrong.