added get utenti
This commit is contained in:
parent
c9fba48d88
commit
1f27bc48d4
File diff suppressed because one or more lines are too long
@ -64,8 +64,8 @@ try {
|
||||
$clienteResponsabile = !empty($result['cliente_responsabile_id']) ? (int) $result['cliente_responsabile_id'] : null;
|
||||
$moltiplicatorePrezzo = !empty($result['moltiplicatore_prezzo_id']) ? (int) $result['moltiplicatore_prezzo_id'] : null;
|
||||
$anagraficaObject = !empty($result['anagrafica_certest_object_id']) ? (int) $result['anagrafica_certest_object_id'] : null;
|
||||
$anagraficaService = !empty($result['anagrafica_certest_service_id'])? (int) $result['anagrafica_certest_service_id']: null;
|
||||
$clienteFornitore = !empty($result['cliente_fornitore_id'])? (int) $result['cliente_fornitore_id']: null;
|
||||
$anagraficaService = !empty($result['anagrafica_certest_service_id']) ? (int) $result['anagrafica_certest_service_id'] : null;
|
||||
$clienteFornitore = !empty($result['cliente_fornitore_id']) ? (int) $result['cliente_fornitore_id'] : null;
|
||||
$consegnaRichiesta = !empty($result['consegna_richiesta']) ? $result['consegna_richiesta'] : null;
|
||||
|
||||
// 🔹 STEP 3: Fetch Parts (including idmatrice)
|
||||
@ -320,16 +320,16 @@ try {
|
||||
// 🔹 STEP 9.5: Importazione da CommessaWeb a Commessa (commentato come richiesto)
|
||||
// Supplier call: POST api/odata/CommessaWeb(XXX)/ImportaCommessa
|
||||
|
||||
$importPayload = ["IdUtente" => 12875]; // user-id
|
||||
$importPayload = ["IdUtente" => 285]; // user-id
|
||||
$importResult = $api->post("CommessaWeb({$commessaId})/ImportaCommessa", $importPayload);
|
||||
|
||||
$importPayloadLog = json_encode($importPayload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
// Logga il POST
|
||||
$logContentStep91 = "curl --location --request POST '{$apiBaseUrl}CommessaWeb({$commessaId})/ImportaCommessa' \\\n" .
|
||||
"--header 'Content-Type: application/json' \\\n" .
|
||||
"--header 'Authorization: Bearer ••••••' \\\n" .
|
||||
"--data '{$importPayloadLog}'\n\n" .
|
||||
"RESPONSE:\n" . json_encode($importResult, JSON_PRETTY_PRINT);
|
||||
"--header 'Content-Type: application/json' \\\n" .
|
||||
"--header 'Authorization: Bearer ••••••' \\\n" .
|
||||
"--data '{$importPayloadLog}'\n\n" .
|
||||
"RESPONSE:\n" . json_encode($importResult, JSON_PRETTY_PRINT);
|
||||
$logFileStep91 = $logDir . "commessa_{$commessaId}_importa_step91_" . time() . ".txt";
|
||||
file_put_contents($logFileStep91, $logContentStep91);
|
||||
|
||||
|
||||
94
public/userarea/get_utenti.php
Normal file
94
public/userarea/get_utenti.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||
require_once __DIR__ . '/class/VisualLimsApiClient.class.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
// Disable PHP error display
|
||||
ini_set('display_errors', '0');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
try {
|
||||
$api = VisualLimsApiClient::getInstance(); // also loads dotenv
|
||||
|
||||
// In simulate mode: return fake users
|
||||
if (($_ENV['SIMULATE_EXPORT_LIMS'] ?? '') === 'true') {
|
||||
$fakeUsers = [
|
||||
[
|
||||
'IdUtente' => 1001,
|
||||
'Nominativo' => 'Utente Simulato 1001'
|
||||
],
|
||||
[
|
||||
'IdUtente' => 1002,
|
||||
'Nominativo' => 'Utente Simulato 1002'
|
||||
]
|
||||
];
|
||||
|
||||
echo json_encode(['value' => $fakeUsers]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// OData parameters
|
||||
$params = [];
|
||||
|
||||
// Build query string
|
||||
$queryString = http_build_query($params);
|
||||
|
||||
// Final endpoint
|
||||
$endpoint = "Utente?$queryString";
|
||||
|
||||
// Function to execute request with retry
|
||||
function makeApiRequest($api, $endpoint, $maxRetries = 3)
|
||||
{
|
||||
for ($retry = 0; $retry < $maxRetries; $retry++) {
|
||||
try {
|
||||
$data = $api->get($endpoint);
|
||||
|
||||
// Save response for debug
|
||||
file_put_contents(__DIR__ . '/utenti_response.json', json_encode($data, JSON_PRETTY_PRINT));
|
||||
|
||||
return $data;
|
||||
} catch (Exception $e) {
|
||||
$errorMessage = $e->getMessage();
|
||||
|
||||
// Retry only on token/auth-related issue
|
||||
if (
|
||||
strpos($errorMessage, 'HTTP 400') !== false &&
|
||||
strpos($errorMessage, 'Cannot persist the object') !== false
|
||||
) {
|
||||
try {
|
||||
$api->refreshToken(); // must exist in VisualLimsApiClient
|
||||
error_log("Tentativo $retry: Refresh token eseguito per endpoint $endpoint");
|
||||
} catch (Exception $refreshEx) {
|
||||
error_log("Errore durante il refresh del token: " . $refreshEx->getMessage());
|
||||
throw new Exception("Impossibile eseguire il refresh del token: " . $refreshEx->getMessage());
|
||||
}
|
||||
|
||||
usleep(500000); // 500 ms
|
||||
continue;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Massimo numero di tentativi raggiunto per $endpoint");
|
||||
}
|
||||
|
||||
// Execute request
|
||||
$data = makeApiRequest($api, $endpoint);
|
||||
|
||||
echo json_encode($data);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
|
||||
$errorResponse = [
|
||||
'error' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'trace' => $e->getTraceAsString()
|
||||
];
|
||||
|
||||
error_log("Errore in get_utenti.php: " . json_encode($errorResponse));
|
||||
echo json_encode($errorResponse);
|
||||
}
|
||||
@ -0,0 +1,60 @@
|
||||
CAMPIONE #0
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/Campione' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{
|
||||
"Commessa": 563528,
|
||||
"Matrice": 3879,
|
||||
"SottoMatrice": null,
|
||||
"SchemaCustomField": 82,
|
||||
"NoteWeb": "Parte AAA",
|
||||
"ConsegnaRichiesta": "2026-01-30"
|
||||
}'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#Campione\/$entity",
|
||||
"IdCampione": 734582,
|
||||
"CodiceCampione": "10978",
|
||||
"CodiceCampioneWeb": "10978",
|
||||
"StatoCampione": "Nuovo",
|
||||
"DataCreazioneWeb": "2026-03-11T14:10:02.1595894+01:00",
|
||||
"RiferimentoWeb": "",
|
||||
"ConsegnaRichiesta": "2026-01-30T00:00:00+01:00",
|
||||
"DataAccettazioneLims": null,
|
||||
"Riferimento": null,
|
||||
"NoteWeb": "Parte AAA",
|
||||
"GruppiRicercati": null
|
||||
}
|
||||
|
||||
---
|
||||
CAMPIONE #1
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/Campione' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{
|
||||
"Commessa": 563528,
|
||||
"Matrice": 3879,
|
||||
"SottoMatrice": null,
|
||||
"SchemaCustomField": 82,
|
||||
"NoteWeb": "PARE BBB",
|
||||
"ConsegnaRichiesta": "2026-01-30"
|
||||
}'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#Campione\/$entity",
|
||||
"IdCampione": 734583,
|
||||
"CodiceCampione": "10979",
|
||||
"CodiceCampioneWeb": "10979",
|
||||
"StatoCampione": "Nuovo",
|
||||
"DataCreazioneWeb": "2026-03-11T14:10:03.9972635+01:00",
|
||||
"RiferimentoWeb": "",
|
||||
"ConsegnaRichiesta": "2026-01-30T00:00:00+01:00",
|
||||
"DataAccettazioneLims": null,
|
||||
"Riferimento": null,
|
||||
"NoteWeb": "PARE BBB",
|
||||
"GruppiRicercati": null
|
||||
}
|
||||
|
||||
---
|
||||
1314
public/userarea/logs/api/commessa_563528_get_step10_1773234618.txt
Normal file
1314
public/userarea/logs/api/commessa_563528_get_step10_1773234618.txt
Normal file
File diff suppressed because it is too large
Load Diff
1314
public/userarea/logs/api/commessa_563528_get_step7_1773234610.txt
Normal file
1314
public/userarea/logs/api/commessa_563528_get_step7_1773234610.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,20 @@
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/CommessaWeb(563528)/ImportaCommessa' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{
|
||||
"IdUtente": 285
|
||||
}'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#CommessaWeb\/$entity",
|
||||
"IdCommessa": 563528,
|
||||
"CodiceCommessa": "26C0029",
|
||||
"RiferimentoCertificato": null,
|
||||
"StatoCommessaWeb": "Elaborata",
|
||||
"DataCreazioneWeb": "2026-03-11T14:10:00.897+01:00",
|
||||
"CodiceCommessaWeb": "26C0029",
|
||||
"DataInviatoWeb": "2026-03-11T14:10:11.76+01:00",
|
||||
"Richiedente": "Test Web Import",
|
||||
"Descrizione": "TEST CommessaWeb"
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
Photos for CommessaWeb 563528 (iddatadb=1259):
|
||||
Total photos found: 2, campioni: 2
|
||||
|
||||
=== Campione 734582 (main) ===
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/Campione(734582)/UploadCampioneFile' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--form 'file=@C:\xampp\htdocs\trf_certest\public\photostrf\1259-20260311130930-104a2ca5-8a4c-4df8-b2ca-a28f518b7b25.jpg'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#CampioneFiles\/$entity",
|
||||
"IdCampioneFile": 1779561,
|
||||
"FileName": "1259-20260311130930-104a2ca5-8a4c-4df8-b2ca-a28f518b7b25.jpg",
|
||||
"Web": false,
|
||||
"AllegaAlRapporto": false,
|
||||
"StampaNelRapporto": false,
|
||||
"ReportGermania": false,
|
||||
"PrimaPagina": false,
|
||||
"Duplica": false,
|
||||
"LastUpdate": "2026-03-11T14:10:06.7051549+01:00",
|
||||
"Titolo": null
|
||||
}
|
||||
|
||||
---
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/Campione(734582)/UploadCampioneFile' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--form 'file=@C:\xampp\htdocs\trf_certest\public\photostrf\1259-20260311130930-1e672dd9-5420-4432-b422-02d8d271c178.jpg'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#CampioneFiles\/$entity",
|
||||
"IdCampioneFile": 1779562,
|
||||
"FileName": "1259-20260311130930-1e672dd9-5420-4432-b422-02d8d271c178.jpg",
|
||||
"Web": false,
|
||||
"AllegaAlRapporto": false,
|
||||
"StampaNelRapporto": false,
|
||||
"ReportGermania": false,
|
||||
"PrimaPagina": false,
|
||||
"Duplica": false,
|
||||
"LastUpdate": "2026-03-11T14:10:08.5442313+01:00",
|
||||
"Titolo": null
|
||||
}
|
||||
|
||||
---
|
||||
@ -0,0 +1,18 @@
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/CommessaWeb(563528)/InviaCommessa' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{}'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#CommessaWeb\/$entity",
|
||||
"IdCommessa": 563528,
|
||||
"CodiceCommessa": "26C0029",
|
||||
"RiferimentoCertificato": null,
|
||||
"StatoCommessaWeb": "Nuova",
|
||||
"DataCreazioneWeb": "2026-03-11T14:10:00.897+01:00",
|
||||
"CodiceCommessaWeb": "26C0029",
|
||||
"DataInviatoWeb": "2026-03-11T14:10:11.7602299+01:00",
|
||||
"Richiedente": "Test Web Import",
|
||||
"Descrizione": "TEST CommessaWeb"
|
||||
}
|
||||
@ -0,0 +1,226 @@
|
||||
curl --location --request PATCH 'https://93.43.5.102/limsapi/api/odata/CommessaWeb(563528)' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{
|
||||
"CommesseCustomFields": [
|
||||
{
|
||||
"IdCommesseCustomFields": 23254249,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254250,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254251,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254252,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254253,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254254,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254260,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254261,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254262,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254264,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254265,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254266,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254267,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254268,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254228,
|
||||
"Valore": "13526"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254229,
|
||||
"Valore": "20262"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254230,
|
||||
"Valore": "ART. PEACH"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254269,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254270,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254271,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254272,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254273,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254274,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254275,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254276,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254277,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254278,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254279,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254280,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254281,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254231,
|
||||
"Valore": "L209A4M00130M7280"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254232,
|
||||
"Valore": "BLACK"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254233,
|
||||
"Valore": "PE007J"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254234,
|
||||
"Valore": "262"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254235,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254236,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254237,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254238,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254239,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254240,
|
||||
"Valore": "Oggi"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254241,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254242,
|
||||
"Valore": "MONCLER"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254243,
|
||||
"Valore": "236"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254244,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254245,
|
||||
"Valore": "BBB"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254246,
|
||||
"Valore": "solocla"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254247,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254248,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254255,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254256,
|
||||
"Valore": "MONCLER"
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254257,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254258,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254259,
|
||||
"Valore": ""
|
||||
},
|
||||
{
|
||||
"IdCommesseCustomFields": 23254263,
|
||||
"Valore": ""
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
RESPONSE:
|
||||
null
|
||||
@ -0,0 +1,28 @@
|
||||
curl --location --request POST 'https://93.43.5.102/limsapi/api/odata/CommessaWeb' \
|
||||
--header 'Content-Type: application/json' \
|
||||
--header 'Authorization: Bearer ••••••' \
|
||||
--data '{
|
||||
"Cliente": 3378,
|
||||
"SchemaCustomField": 82,
|
||||
"Richiedente": "Test Web Import",
|
||||
"Descrizione": "TEST CommessaWeb",
|
||||
"ClienteResponsabile": 10653,
|
||||
"MoltiplicatorePrezzo": 1,
|
||||
"AnagraficaCertestObject": 8960,
|
||||
"AnagraficaCertestService": 9010,
|
||||
"ClienteFornitore": null
|
||||
}'
|
||||
|
||||
RESPONSE:
|
||||
{
|
||||
"@odata.context": "https:\/\/bvcpsitaly-elims.com\/limsapi\/api\/odata\/$metadata#CommessaWeb\/$entity",
|
||||
"IdCommessa": 563528,
|
||||
"CodiceCommessa": "26C0029",
|
||||
"RiferimentoCertificato": null,
|
||||
"StatoCommessaWeb": "Nuova",
|
||||
"DataCreazioneWeb": "2026-03-11T14:10:00.8960358+01:00",
|
||||
"CodiceCommessaWeb": "26C0029",
|
||||
"DataInviatoWeb": null,
|
||||
"Richiedente": "Test Web Import",
|
||||
"Descrizione": "TEST CommessaWeb"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user