Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 447a0d1dea | |||
| 5b47416841 | |||
| 3e4a627ca7 | |||
| 25d4519684 | |||
| 34d4dc8660 | |||
| 1510ef03f1 | |||
| ce8c95921f | |||
| 095a6ae879 | |||
| 296143016a | |||
| 3aa2504f3c | |||
| c1a396f246 | |||
| a45ba1c8b3 | |||
| 7a944a73f7 | |||
| 71595cc8de | |||
| f89dbd0c23 | |||
| 9ba859e15b | |||
| 672e448e9a | |||
| 0749032fbc | |||
| d692614f70 |
@@ -1,47 +0,0 @@
|
||||
APP_ENV=production
|
||||
APP_DEBUG=true
|
||||
APP_KEY=base64:C+sutHm6xP5sE4QXhoZFhYjArlVN11s2mDU1F8beUkM=
|
||||
APP_URL=http://vanguard.test
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST="localhost"
|
||||
DB_DATABASE="trfcertest"
|
||||
DB_USERNAME="solocla"
|
||||
DB_PASSWORD="!Massarosa2"
|
||||
DB_PREFIX="auth_"
|
||||
|
||||
BROADCAST_DRIVER=log
|
||||
CACHE_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=mail
|
||||
MAIL_FROM_NAME=Vanguard
|
||||
MAIL_FROM_ADDRESS=vanguard@test.dev
|
||||
MAIL_HOST=smtp.mailtrap.io
|
||||
MAIL_PORT=2525
|
||||
MAIL_USERNAME=null
|
||||
MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
|
||||
PUSHER_APP_ID=
|
||||
PUSHER_APP_KEY=
|
||||
PUSHER_APP_SECRET=
|
||||
PUSHER_APP_CLUSTER=mt1
|
||||
|
||||
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
|
||||
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
|
||||
|
||||
# Credenziali API VisualLims
|
||||
API_BASE_URL=https://93.43.5.102/limsapi
|
||||
API_USERNAME=WebApiUser
|
||||
API_PASSWORD=webapiuser01
|
||||
|
||||
BASE_URL=http://localhost:8000/userarea/
|
||||
@@ -32,3 +32,4 @@ $langdatatables = [
|
||||
"paginate_next" => "Next",
|
||||
"paginate_previous" => "Previous"
|
||||
];
|
||||
$quotationstitle = "Quotations";
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
* Trying 93.43.5.102:443...
|
||||
* Connected to 93.43.5.102 (93.43.5.102) port 443
|
||||
* ALPN: curl offers h2,http/1.1
|
||||
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
|
||||
* ALPN: server accepted h2
|
||||
* Server certificate:
|
||||
* subject: C=FR; ST=Île-de-France; O=Bureau Veritas; CN=bvcpsitaly-elims.it
|
||||
* start date: Feb 17 00:00:00 2025 GMT
|
||||
* expire date: Feb 17 23:59:59 2026 GMT
|
||||
* issuer: C=US; O=Corporation Service Company; CN=Corporation Service Company RSA OV SSL CA
|
||||
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
|
||||
* using HTTP/2
|
||||
* [HTTP/2] [1] OPENED stream for https://93.43.5.102/limsapi/api/authentication/authenticate
|
||||
* [HTTP/2] [1] [:method: POST]
|
||||
* [HTTP/2] [1] [:scheme: https]
|
||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||
* [HTTP/2] [1] [:path: /limsapi/api/authentication/authenticate]
|
||||
* [HTTP/2] [1] [content-type: application/json]
|
||||
* [HTTP/2] [1] [accept: application/json]
|
||||
* [HTTP/2] [1] [content-length: 51]
|
||||
> POST /limsapi/api/authentication/authenticate HTTP/2
|
||||
Host: 93.43.5.102
|
||||
Content-Type: application/json
|
||||
Accept: application/json
|
||||
Content-Length: 51
|
||||
|
||||
< HTTP/2 200
|
||||
< cache-control: max-age=0
|
||||
< content-type: application/json; charset=utf-8
|
||||
< server: Microsoft-IIS/10.0
|
||||
< strict-transport-security: max-age=2592000
|
||||
< x-powered-by: ASP.NET
|
||||
< x-content-type-options: nosniff
|
||||
< date: Fri, 29 Aug 2025 14:28:29 GMT
|
||||
<
|
||||
* Connection #0 to host 93.43.5.102 left intact
|
||||
@@ -1,35 +0,0 @@
|
||||
* Trying 93.43.5.102:443...
|
||||
* Connected to 93.43.5.102 (93.43.5.102) port 443
|
||||
* ALPN: curl offers h2,http/1.1
|
||||
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
|
||||
* ALPN: server accepted h2
|
||||
* Server certificate:
|
||||
* subject: C=FR; ST=Île-de-France; O=Bureau Veritas; CN=bvcpsitaly-elims.it
|
||||
* start date: Feb 17 00:00:00 2025 GMT
|
||||
* expire date: Feb 17 23:59:59 2026 GMT
|
||||
* issuer: C=US; O=Corporation Service Company; CN=Corporation Service Company RSA OV SSL CA
|
||||
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
|
||||
* using HTTP/2
|
||||
* [HTTP/2] [1] OPENED stream for https://93.43.5.102/limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues
|
||||
* [HTTP/2] [1] [:method: GET]
|
||||
* [HTTP/2] [1] [:scheme: https]
|
||||
* [HTTP/2] [1] [:authority: 93.43.5.102]
|
||||
* [HTTP/2] [1] [:path: /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues]
|
||||
* [HTTP/2] [1] [authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NjQ4NDkwOSwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.VPLdAAvg-D2ReaPr7erRrgX70RQsySvuBXN284HFQ74]
|
||||
* [HTTP/2] [1] [accept: application/json]
|
||||
> GET /limsapi/api/odata/CustomField(1083)?$expand=CustomFieldsValues HTTP/2
|
||||
Host: 93.43.5.102
|
||||
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1laWRlbnRpZmllciI6IjQ5MiIsIlhhZlNlY3VyaXR5QXV0aFBhc3NlZCI6IlhhZlNlY3VyaXR5QXV0aFBhc3NlZCIsImh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzLzIwMDUvMDUvaWRlbnRpdHkvY2xhaW1zL25hbWUiOiJXZWJBcGlVc2VyIiwiWGFmU2VjdXJpdHkiOiJYYWZTZWN1cml0eSIsIlhhZkxvZ29uUGFyYW1zIjoicTFZS0xVNHQ4a3ZNVFZXeVVncFBUWElzeUFRSktPa29CU1FXRjVmbkY2VUF4Y3RUa3hJTE1rdUI0Z2FHU3JVQSIsImV4cCI6MTc1NjQ4NDkwOSwiaXNzIjoiTXkiLCJhdWQiOiJodHRwOi8vbG9jYWxob3N0OjQyMDAifQ.VPLdAAvg-D2ReaPr7erRrgX70RQsySvuBXN284HFQ74
|
||||
Accept: application/json
|
||||
|
||||
< HTTP/2 200
|
||||
< cache-control: max-age=0
|
||||
< content-type: application/json; odata.metadata=minimal; odata.streaming=true; charset=utf-8
|
||||
< server: Microsoft-IIS/10.0
|
||||
< strict-transport-security: max-age=2592000
|
||||
< odata-version: 4.0
|
||||
< x-powered-by: ASP.NET
|
||||
< x-content-type-options: nosniff
|
||||
< date: Fri, 29 Aug 2025 14:28:33 GMT
|
||||
<
|
||||
* Connection #0 to host 93.43.5.102 left intact
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$partId = $data['part_id'] ?? null;
|
||||
|
||||
if (!$partId) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID parte mancante']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("DELETE FROM identification_parts WHERE id = :part_id");
|
||||
$stmt->execute([':part_id' => $partId]);
|
||||
$rowCount = $stmt->rowCount();
|
||||
if ($rowCount > 0) {
|
||||
echo json_encode(['success' => true, 'message' => 'Parte eliminata con successo']);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Nessuna parte trovata con ID ' . $partId]);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nell\'eliminazione: ' . $e->getMessage()]);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# Swagger Codegen Ignore
|
||||
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -0,0 +1 @@
|
||||
3.0.34
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -11,3 +11,4 @@
|
||||
2025-08-26 16:48:44 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||
2025-08-26 16:49:24 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||
2025-08-26 16:50:23 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||
2025-09-08 08:39:17 - Risposta non JSON valida: <?xml version="1.0" encoding="utf-8"?><edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"><edmx:DataServices><Schema Namespace="DevExpress.ExpressApp.SystemModule" xmlns="http://docs.oasis-open.org/odata/ns/edm"><EntityType Name="DashboardViewItemDescriptor"><Key><PropertyRef Name="ViewId" /></Key><Property Name="ViewId" Type="Edm.String" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem" BaseType="DevExpress.ExpressApp.NonPersistentLiteObject" Abstract="true"><Property Name="Visibility" Type="DevExpress.ExpressApp.Editors.ViewItemVisibility" Nullable="false" /></EntityType><EntityType Name="DashboardOrganizationItem_1OfIModelDashboardViewItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem" Abstract="true" /><EntityType Name="ViewDashboardOrganizationItem" BaseType="DevExpress.ExpressApp.SystemModule.DashboardOrganizationItem_1OfIModelDashboardViewItem"><Property Name="ObjectType" Type="System.Type" /><Proper
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once dirname(__DIR__, 2) . '/vendor/autoload.php';
|
||||
require_once dirname(__FILE__) . '/class/VisualLimsApiClient.class.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
ini_set('display_errors', '0');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
try {
|
||||
$api = VisualLimsApiClient::getInstance();
|
||||
|
||||
// ID della CommessaWeb specifica (cambialo di volta in volta)
|
||||
$id = 529435; // TODO: Cambia questo valore con l'ID desiderato
|
||||
|
||||
// Endpoint per recuperare la CommessaWeb specifica con espansione dello schema custom
|
||||
$endpoint = "CommessaWeb({$id})";
|
||||
|
||||
// Opzioni per l'espansione: includi OrderCustomFields per ottenere i campi custom dello schema assegnato all'ordine
|
||||
$options = ['$expand' => 'OrderCustomFields'];
|
||||
|
||||
// Debug: salva URL usato
|
||||
$base_url = 'https://93.43.5.102/limsapi/api/odata/';
|
||||
$query = http_build_query($options);
|
||||
$full_url = $base_url . $endpoint . ($query ? '?' . $query : '');
|
||||
file_put_contents(__DIR__ . '/last_url.txt', $full_url . PHP_EOL, FILE_APPEND);
|
||||
|
||||
// Chiamata API
|
||||
$data = $api->get($endpoint, $options);
|
||||
|
||||
// Salva il JSON in locale
|
||||
file_put_contents(__DIR__ . '/commessaweb_schema_response.json', json_encode($data, JSON_PRETTY_PRINT));
|
||||
|
||||
echo json_encode($data);
|
||||
} catch (Exception $e) {
|
||||
file_put_contents(__DIR__ . '/error_log.txt', date('Y-m-d H:i:s') . ' - ' . $e->getMessage() . PHP_EOL, FILE_APPEND);
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
@@ -948,6 +948,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
</div>
|
||||
<?php include('jsinclude.php'); ?>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/5.3.1/fabric.min.js"></script>
|
||||
<script src="photos.js"></script>
|
||||
<script src="parts.js"></script>
|
||||
<script src="tracking.js"></script>
|
||||
|
||||
File diff suppressed because one or more lines are too long
+231
-150
@@ -21,8 +21,8 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['template_id']) || !i
|
||||
|
||||
$template_id = intval($_POST['template_id']) ?? $_SESSION['template_id'];
|
||||
$selected_rows = $_POST['selected_rows'] ?? $_SESSION['selected_rows'];
|
||||
$columns = json_decode($_POST['columns'], true) ?? $_SESSION['columns']; // Header dell'XLS
|
||||
$rows = json_decode($_POST['rows'], true) ?? $_SESSION['rows']; // Dati dell'XLS
|
||||
$columns = json_decode($_POST['columns'], true) ?? $_SESSION['columns'];
|
||||
$rows = json_decode($_POST['rows'], true) ?? $_SESSION['rows'];
|
||||
$newFilename = htmlspecialchars($_POST['filename']) ?? $_SESSION['filename'];
|
||||
|
||||
// Log dei dati ricevuti
|
||||
@@ -31,7 +31,7 @@ error_log("Columns: " . json_encode($columns));
|
||||
error_log("Rows: " . json_encode($rows));
|
||||
|
||||
// Recupera l'ID dell'utente loggato
|
||||
$user_id = $iduserlogin ?? 1; // Default a 1 se non definito
|
||||
$user_id = $iduserlogin ?? 1;
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
@@ -98,26 +98,26 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
<?php include('cssinclude.php'); ?>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2Lw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<style>
|
||||
/* Colori pastello per input/select */
|
||||
.cell-changed {
|
||||
background-color: #fff3b0 !important;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
input.auto-input,
|
||||
select.auto-input {
|
||||
background-color: #d4edda;
|
||||
/* Verde pastello */
|
||||
}
|
||||
|
||||
input.manual-input,
|
||||
select.manual-input {
|
||||
background-color: #fff3cd;
|
||||
/* Giallino pastello */
|
||||
}
|
||||
|
||||
input.required-input,
|
||||
select.required-input {
|
||||
background-color: #f8d7da;
|
||||
/* Rossino chiaro */
|
||||
}
|
||||
|
||||
/* Stili base per input/select */
|
||||
input,
|
||||
select {
|
||||
width: 100%;
|
||||
@@ -128,14 +128,11 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* Mantieni leggibilità del testo */
|
||||
input,
|
||||
select {
|
||||
color: #333;
|
||||
/* Colore scuro per contrasto */
|
||||
}
|
||||
|
||||
/* Stili per i badge di stato */
|
||||
.status-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
@@ -161,7 +158,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Stili esistenti rimangono invariati */
|
||||
.grid-container {
|
||||
overflow-x: auto;
|
||||
max-width: 100%;
|
||||
@@ -254,6 +250,11 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.grid-top .save-all-cell {
|
||||
flex: 0 0 210px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.propagate-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
@@ -370,7 +371,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
|
||||
}
|
||||
|
||||
/* Stile per l'header dei pulsanti combinati */
|
||||
.grid-cell.button-cell,
|
||||
.grid-header.button-header {
|
||||
min-width: 210px !important;
|
||||
@@ -391,6 +391,20 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
background-color: #d4edda !important;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.save-all-btn {
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
padding: 8px 16px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.save-all-btn:hover {
|
||||
background-color: #218838;
|
||||
}
|
||||
</style>
|
||||
<title>Edit Imported Data - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
||||
</head>
|
||||
@@ -413,6 +427,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
<h6 class="mb-0">Modifica Dati Importati</h6>
|
||||
<div id="unsavedChanges" style="display:none; color: red; font-weight: bold; margin:10px 0;">
|
||||
⚠️ Unsaved changes detected! Please save before leaving this page.
|
||||
<ul id="changedFields" style="margin-top:5px; font-weight:normal; color:darkred;"></ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -420,9 +435,10 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
<div class="card-body">
|
||||
<form id="editForm">
|
||||
<div class="grid-container">
|
||||
<!-- Riga superiore per gli input dei campi manuali -->
|
||||
<div class="grid-top">
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 210px;"></div> <!-- Actions -->
|
||||
<div class="grid-cell save-all-cell">
|
||||
<button type="button" class="save-all-btn" title="Save All Rows"><i class="fas fa-save"></i> Save All</button>
|
||||
</div>
|
||||
<?php if ($mainFieldMapping): ?>
|
||||
<div class="grid-cell" style="flex: 0 0 150px;">
|
||||
<?php
|
||||
@@ -450,9 +466,8 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="grid-cell" style="flex: 0 0 150px;"></div> <!-- status -->
|
||||
<div class="grid-cell" style="flex: 0 0 150px;"></div>
|
||||
<?php
|
||||
// Campi automatici (is_manual = 0) escluso main_field
|
||||
$autoIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if (!$mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
@@ -471,7 +486,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$autoIndex++;
|
||||
}
|
||||
}
|
||||
// Campi manuali (is_manual = 1) escluso main_field
|
||||
$manualIndex = 0;
|
||||
foreach ($allMappings as $mapping) {
|
||||
if ($mapping['is_manual'] && $mapping['main_field'] != 1) {
|
||||
@@ -483,7 +497,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if ($mapping['is_required']) $inputClass .= ' required-input';
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'>";
|
||||
if ($mapping['data_type'] === 'SceltaMultipla') {
|
||||
echo "<select class='custom-field dropdown-select $inputClass' data-column='manual_$manualIndex' data-field-id='{$mapping['field_id']}' data-selected-value='" . htmlspecialchars($fieldValue) . "' " . ($mapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<select class='custom-field dropdown-select $inputClass' data-column='manual_$manualIndex' data-field-id='{$mapping['field_id']}' data-selected-value='" . htmlspecialchars($fieldValue) . "' " . ($mainFieldMapping['is_required'] ? 'required' : '') . ">";
|
||||
echo "<option value=''>Seleziona...</option>";
|
||||
echo "</select>";
|
||||
} elseif ($mapping['data_type'] === 'DATE') {
|
||||
@@ -498,15 +512,14 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$manualIndex++;
|
||||
}
|
||||
}
|
||||
echo "<div class='grid-cell' style='flex: 0 0 200px;'></div>"; // AWB
|
||||
echo "<div class='grid-cell' style='flex: 0 0 250px;'></div>"; // Tracking Info
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>"; // importreferencecode
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>"; // filename_import
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>"; // importdate
|
||||
echo "<div class='grid-cell' style='flex: 0 0 200px;'></div>";
|
||||
echo "<div class='grid-cell' style='flex: 0 0 250px;'></div>";
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
||||
echo "<div class='grid-cell' style='flex: 0 0 150px;'></div>";
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Header della tabella -->
|
||||
<div class="grid-row">
|
||||
<div class="grid-header button-header" style="flex: 0 0 210px;">Actions</div>
|
||||
<?php if ($mainFieldMapping): ?>
|
||||
@@ -543,7 +556,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
?>
|
||||
</div>
|
||||
|
||||
<!-- Righe della tabella -->
|
||||
<?php foreach ($importedData as $index => $row): ?>
|
||||
<div class="grid-row" data-id="<?= $row['iddatadb'] ?>">
|
||||
<div class="grid-cell button-cell" style="flex: 0 0 210px; position: relative;">
|
||||
@@ -692,27 +704,200 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
</div>
|
||||
<?php include('jsinclude.php'); ?>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/5.3.1/fabric.min.js"></script>
|
||||
<script src="photos.js"></script>
|
||||
<script src="parts.js"></script>
|
||||
<script src="tracking.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
console.log("Page loaded, initializing event listeners");
|
||||
|
||||
const inputs = document.querySelectorAll(".cell-input, .dropdown-select, .carrier-select, .awb-input");
|
||||
const unsavedDiv = document.getElementById("unsavedChanges");
|
||||
const changedList = document.getElementById("changedFields");
|
||||
let hasChanges = false;
|
||||
let changedFields = {};
|
||||
|
||||
function renderChangedList() {
|
||||
console.log("Rendering changed fields list:", changedFields);
|
||||
changedList.innerHTML = "";
|
||||
Object.keys(changedFields).forEach(rowIndex => {
|
||||
const fields = changedFields[rowIndex];
|
||||
if (fields.length > 0) {
|
||||
const li = document.createElement("li");
|
||||
li.textContent = `Row ${parseInt(rowIndex) + 1}: ${fields.join(", ")}`;
|
||||
changedList.appendChild(li);
|
||||
}
|
||||
});
|
||||
unsavedDiv.style.display = Object.keys(changedFields).length > 0 ? "block" : "none";
|
||||
}
|
||||
|
||||
inputs.forEach(el => {
|
||||
el.addEventListener("change", () => {
|
||||
console.log("Input changed:", el.name);
|
||||
hasChanges = true;
|
||||
unsavedDiv.style.display = "block";
|
||||
const gridCell = el.closest(".grid-cell");
|
||||
const colIndex = gridCell?.dataset.index;
|
||||
const rowIndex = gridCell?.dataset.row;
|
||||
let label = "Unknown field";
|
||||
|
||||
if (colIndex) {
|
||||
const header = document.querySelector(`.grid-header[data-index="${colIndex}"]`);
|
||||
if (header) {
|
||||
label = header.textContent.replace(":", "").trim();
|
||||
}
|
||||
}
|
||||
|
||||
if (rowIndex !== undefined) {
|
||||
if (!changedFields[rowIndex]) {
|
||||
changedFields[rowIndex] = [];
|
||||
}
|
||||
if (!changedFields[rowIndex].includes(label)) {
|
||||
changedFields[rowIndex].push(label);
|
||||
}
|
||||
gridCell.classList.add("cell-changed");
|
||||
}
|
||||
|
||||
renderChangedList();
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll(".save-btn").forEach(btn => {
|
||||
btn.addEventListener("click", () => {
|
||||
hasChanges = false;
|
||||
unsavedDiv.style.display = "none";
|
||||
const rowIndex = btn.dataset.row;
|
||||
console.log(`Saving row ${rowIndex}`);
|
||||
const row = btn.closest('.grid-row');
|
||||
const iddatadb = row.getAttribute('data-id');
|
||||
const formData = new FormData();
|
||||
|
||||
const inputs = row.querySelectorAll(`input[name^="rows[${rowIndex}][details]"], select[name^="rows[${rowIndex}][details]"]`);
|
||||
inputs.forEach(input => {
|
||||
const matches = input.name.match(/rows\[\d+\]\[details\]\[(\d+)\]\[field_value\]/);
|
||||
if (matches) {
|
||||
const mappingId = matches[1];
|
||||
formData.append(`details${mappingId}field_value`, input.value);
|
||||
if (input.tagName === 'SELECT' && input.classList.contains('dropdown-select')) {
|
||||
input.setAttribute('data-selected-value', input.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
formData.append('iddatadb', iddatadb);
|
||||
|
||||
fetch('save_edited_row.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
console.log("Save response:", data);
|
||||
if (data.success) {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
cells.forEach(cell => {
|
||||
cell.classList.remove('flash-success');
|
||||
void cell.offsetWidth;
|
||||
cell.classList.add('flash-success');
|
||||
});
|
||||
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
||||
|
||||
if (changedFields[rowIndex]) {
|
||||
delete changedFields[rowIndex];
|
||||
document.querySelectorAll(`.grid-cell[data-row="${rowIndex}"]`)
|
||||
.forEach(cell => cell.classList.remove("cell-changed"));
|
||||
renderChangedList();
|
||||
hasChanges = Object.keys(changedFields).length > 0;
|
||||
}
|
||||
|
||||
alert('Salvataggio riga avvenuto con successo!');
|
||||
} else {
|
||||
alert('Errore durante il salvataggio: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Save error:", error);
|
||||
alert('Errore durante il salvataggio: ' + error.message);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelector('.save-all-btn').addEventListener('click', async () => {
|
||||
console.log("Saving all rows");
|
||||
const rows = document.querySelectorAll('.grid-row');
|
||||
let successCount = 0;
|
||||
let errorMessages = [];
|
||||
|
||||
for (const row of rows) {
|
||||
const saveBtn = row.querySelector('.save-btn');
|
||||
if (!saveBtn) {
|
||||
console.warn(`No save button found in row with data-id: ${row.getAttribute('data-id')}`);
|
||||
continue;
|
||||
}
|
||||
const rowIndex = saveBtn.dataset.row;
|
||||
const iddatadb = row.getAttribute('data-id');
|
||||
if (!rowIndex || !iddatadb) {
|
||||
console.warn(`Missing rowIndex or iddatadb in row:`, row);
|
||||
continue;
|
||||
}
|
||||
console.log(`Processing row ${rowIndex} with iddatadb ${iddatadb}`);
|
||||
const formData = new FormData();
|
||||
|
||||
const inputs = row.querySelectorAll(`input[name^="rows[${rowIndex}][details]"], select[name^="rows[${rowIndex}][details]"]`);
|
||||
inputs.forEach(input => {
|
||||
const matches = input.name.match(/rows\[\d+\]\[details\]\[(\d+)\]\[field_value\]/);
|
||||
if (matches) {
|
||||
const mappingId = matches[1];
|
||||
formData.append(`details${mappingId}field_value`, input.value);
|
||||
if (input.tagName === 'SELECT' && input.classList.contains('dropdown-select')) {
|
||||
input.setAttribute('data-selected-value', input.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
formData.append('iddatadb', iddatadb);
|
||||
|
||||
try {
|
||||
const response = await fetch('save_edited_row.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
const data = await response.json();
|
||||
|
||||
console.log(`Row ${rowIndex} save response:`, data);
|
||||
if (data.success) {
|
||||
successCount++;
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
cells.forEach(cell => {
|
||||
cell.classList.remove('flash-success');
|
||||
void cell.offsetWidth;
|
||||
cell.classList.add('flash-success');
|
||||
});
|
||||
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
||||
|
||||
if (changedFields[rowIndex]) {
|
||||
delete changedFields[rowIndex];
|
||||
document.querySelectorAll(`.grid-cell[data-row="${rowIndex}"]`)
|
||||
.forEach(cell => cell.classList.remove("cell-changed"));
|
||||
}
|
||||
} else {
|
||||
errorMessages.push(`Riga ${parseInt(rowIndex) + 1}: ${data.message}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Row ${rowIndex} save error:`, error);
|
||||
errorMessages.push(`Riga ${parseInt(rowIndex) + 1}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
renderChangedList();
|
||||
hasChanges = Object.keys(changedFields).length > 0;
|
||||
console.log(`Save all completed: ${successCount} successes, ${errorMessages.length} errors`);
|
||||
|
||||
if (errorMessages.length === 0) {
|
||||
alert(`Tutte le ${successCount} righe salvate con successo!`);
|
||||
} else {
|
||||
alert(`Salvate ${successCount} righe con successo.\nErrori:\n${errorMessages.join('\n')}`);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", function(e) {
|
||||
@@ -723,9 +908,9 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
console.log("Initializing cell expansion and propagation");
|
||||
const inputs = document.querySelectorAll('.cell-input');
|
||||
inputs.forEach(input => {
|
||||
input.addEventListener('focus', function() {
|
||||
@@ -736,48 +921,10 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
});
|
||||
});
|
||||
|
||||
const saveButtons = document.querySelectorAll('.save-btn');
|
||||
saveButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const rowIndex = this.getAttribute('data-row');
|
||||
const row = this.closest('.grid-row');
|
||||
const iddatadb = row.getAttribute('data-id');
|
||||
const formData = new FormData();
|
||||
|
||||
const inputs = row.querySelectorAll(`input[name^="rows[${rowIndex}]"], select[name^="rows[${rowIndex}]"]`);
|
||||
inputs.forEach(input => {
|
||||
const name = input.name.replace(`rows[${rowIndex}]`, '').replace(/\[|\]/g, '');
|
||||
formData.append(name, input.value);
|
||||
});
|
||||
formData.append('iddatadb', iddatadb);
|
||||
formData.append('mapping', JSON.stringify(<?= json_encode($allMappings) ?>));
|
||||
|
||||
fetch('save_edited_row.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
cells.forEach(cell => {
|
||||
cell.classList.remove('flash-success');
|
||||
void cell.offsetWidth;
|
||||
cell.classList.add('flash-success');
|
||||
});
|
||||
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
||||
alert('Salvataggio avvenuto con successo!');
|
||||
} else {
|
||||
alert('Errore durante il salvataggio: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => alert('Errore durante il salvataggio: ' + error.message));
|
||||
});
|
||||
});
|
||||
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
console.log("Propagating value for column:", this.getAttribute('data-column'));
|
||||
const column = this.getAttribute('data-column');
|
||||
const input = this.previousElementSibling;
|
||||
const value = input.value;
|
||||
@@ -796,6 +943,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if (targetInput) {
|
||||
targetInput.value = value;
|
||||
if (targetInput.tagName === 'SELECT') {
|
||||
targetInput.setAttribute('data-selected-value', value);
|
||||
const event = new Event('change');
|
||||
targetInput.dispatchEvent(event);
|
||||
}
|
||||
@@ -813,6 +961,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
let columnIndex = 0;
|
||||
resizers.forEach(resizer => {
|
||||
resizer.addEventListener('mousedown', function(e) {
|
||||
console.log("Starting column resize");
|
||||
currentResizer = resizer;
|
||||
const header = resizer.parentElement;
|
||||
columnIndex = header.getAttribute('data-index');
|
||||
@@ -835,6 +984,7 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
function stopResize() {
|
||||
if (currentResizer) {
|
||||
console.log("Stopping column resize");
|
||||
document.removeEventListener('mousemove', resize);
|
||||
document.removeEventListener('mouseup', stopResize);
|
||||
currentResizer = null;
|
||||
@@ -845,11 +995,15 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
console.log("Initializing dropdown population");
|
||||
const dropdownData = {};
|
||||
|
||||
async function populateDropdowns() {
|
||||
const dropdowns = document.querySelectorAll('.dropdown-select');
|
||||
if (dropdowns.length === 0) return;
|
||||
if (dropdowns.length === 0) {
|
||||
console.log("No dropdowns found");
|
||||
return;
|
||||
}
|
||||
|
||||
const uniqueFieldIds = [
|
||||
...new Set(Array.from(dropdowns).map(d => d.getAttribute('data-field-id')))
|
||||
@@ -858,31 +1012,34 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
const missingFieldIds = uniqueFieldIds.filter(fieldId => !dropdownData[fieldId]);
|
||||
|
||||
if (missingFieldIds.length > 0) {
|
||||
console.log("Fetching dropdown data for field IDs:", missingFieldIds);
|
||||
try {
|
||||
const response = await fetch(
|
||||
`get_customfield_values.php?field_ids=${missingFieldIds.join(",")}`
|
||||
);
|
||||
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.error) {
|
||||
console.error("Errore fetch multiplo:", data.error);
|
||||
console.error("Fetch error:", data.error);
|
||||
} else {
|
||||
for (const fieldId of Object.keys(data)) {
|
||||
dropdownData[fieldId] = data[fieldId] || [];
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Errore generale nel fetch multiplo:", error);
|
||||
console.error("Fetch error:", error);
|
||||
}
|
||||
}
|
||||
|
||||
dropdowns.forEach(dropdown => {
|
||||
const fieldId = dropdown.getAttribute('data-field-id');
|
||||
const selectedValue = dropdown.getAttribute('data-selected-value') || '';
|
||||
const currentValue = dropdown.value; // Preserva il valore corrente
|
||||
const currentValue = dropdown.value;
|
||||
|
||||
if (!fieldId || !dropdownData[fieldId]) {
|
||||
dropdown.innerHTML = '<option value="">Errore nel caricamento</option>';
|
||||
console.warn(`No data for fieldId ${fieldId}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -891,7 +1048,6 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
const option = document.createElement('option');
|
||||
option.value = value.IdCustomFieldsValue;
|
||||
option.textContent = value.Valore;
|
||||
// Usa il valore corrente se disponibile, altrimenti usa data-selected-value
|
||||
if (currentValue && currentValue === String(value.IdCustomFieldsValue)) {
|
||||
option.selected = true;
|
||||
} else if (!currentValue && selectedValue === String(value.IdCustomFieldsValue)) {
|
||||
@@ -902,87 +1058,12 @@ foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
if ((currentValue || selectedValue) && dropdown.value !== (currentValue || selectedValue)) {
|
||||
dropdown.value = '';
|
||||
console.warn(`Valore ${currentValue || selectedValue} non trovato per fieldId ${fieldId}`);
|
||||
console.warn(`Value ${currentValue || selectedValue} not found for fieldId ${fieldId}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Chiama populateDropdowns solo al caricamento iniziale
|
||||
populateDropdowns();
|
||||
|
||||
document.querySelectorAll('.save-btn').forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
const rowIndex = this.getAttribute('data-row');
|
||||
const row = this.closest('.grid-row');
|
||||
const iddatadb = row.getAttribute('data-id');
|
||||
const formData = new FormData();
|
||||
|
||||
const inputs = row.querySelectorAll(`input[name^="rows[${rowIndex}]"], select[name^="rows[${rowIndex}]"]`);
|
||||
inputs.forEach(input => {
|
||||
const name = input.name.replace(`rows[${rowIndex}]`, '').replace(/\[|\]/g, '');
|
||||
formData.append(name, input.value);
|
||||
// Aggiorna data-selected-value per i dropdown
|
||||
if (input.tagName === 'SELECT' && input.classList.contains('dropdown-select')) {
|
||||
input.setAttribute('data-selected-value', input.value);
|
||||
}
|
||||
});
|
||||
formData.append('iddatadb', iddatadb);
|
||||
formData.append('mapping', JSON.stringify(<?= json_encode($allMappings) ?>));
|
||||
|
||||
fetch('save_edited_row.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
cells.forEach(cell => {
|
||||
cell.classList.remove('flash-success');
|
||||
void cell.offsetWidth;
|
||||
cell.classList.add('flash-success');
|
||||
});
|
||||
setTimeout(() => cells.forEach(cell => cell.classList.remove('flash-success')), 500);
|
||||
alert('Salvataggio avvenuto con successo!');
|
||||
} else {
|
||||
alert('Errore durante il salvataggio: ' + data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => alert('Errore durante il salvataggio: ' + error.message));
|
||||
});
|
||||
});
|
||||
|
||||
const propagateButtons = document.querySelectorAll('.propagate-btn');
|
||||
propagateButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const column = this.getAttribute('data-column');
|
||||
const input = this.previousElementSibling;
|
||||
const value = input.value;
|
||||
|
||||
const gridTopCells = document.querySelector('.grid-top').querySelectorAll('.grid-cell');
|
||||
const targetTopIndex = Array.from(gridTopCells).findIndex(cell =>
|
||||
cell.querySelector('.propagate-btn[data-column="' + column + '"]')
|
||||
);
|
||||
|
||||
if (targetTopIndex !== -1) {
|
||||
const rows = document.querySelectorAll('.grid-row');
|
||||
rows.forEach(row => {
|
||||
const cells = row.querySelectorAll('.grid-cell');
|
||||
if (cells.length > targetTopIndex) {
|
||||
const targetInput = cells[targetTopIndex].querySelector('select.dropdown-select, input');
|
||||
if (targetInput) {
|
||||
targetInput.value = value;
|
||||
if (targetInput.tagName === 'SELECT') {
|
||||
targetInput.setAttribute('data-selected-value', value); // Aggiorna anche qui
|
||||
const event = new Event('change');
|
||||
targetInput.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -41,7 +41,21 @@
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>-->
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:;" class="has-arrow">
|
||||
<div class="parent-icon"><i class="bx bx-category"></i>
|
||||
</div>
|
||||
<div class="menu-title">Other Functions</div>
|
||||
</a>
|
||||
<ul>
|
||||
<li> <a href="quotations.php"><i class='bx bx-radio-circle'></i><?php echo $quotationstitle; ?></a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$idquotations = $_GET['idquotations'] ?? null;
|
||||
|
||||
if (!$idquotations) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID quotations mancante']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT id, idquotations, part_number, part_description FROM identification_parts WHERE idquotations = :idquotations ORDER BY part_number ASC");
|
||||
$stmt->execute([':idquotations' => $idquotations]);
|
||||
$parts = $stmt->fetchAll();
|
||||
|
||||
echo json_encode(['success' => true, 'parts' => $parts]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nel caricamento: ' . $e->getMessage()]);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// load_photo_quotation.php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$idquotations = isset($_GET['idquotations']) ? intval($_GET['idquotations']) : null;
|
||||
|
||||
if (!$idquotations) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID quotation mancante']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Seleziona le foto per il dato idquotations dalla tabella datadb_photos
|
||||
$stmt = $pdo->prepare("SELECT id, file_path FROM datadb_photos WHERE idquotations = ?");
|
||||
$stmt->execute([$idquotations]);
|
||||
$photos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($photos && count($photos) > 0) {
|
||||
$photoPaths = array_map(function ($photo) {
|
||||
return '../photostrf/' . $photo['file_path'];
|
||||
}, $photos);
|
||||
echo json_encode(['success' => true, 'photos' => $photoPaths]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Nessuna foto trovata']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nel caricamento: ' . $e->getMessage()]);
|
||||
}
|
||||
@@ -21,7 +21,7 @@ $schemajson = $template['schemajson'] ? json_decode($template['schemajson'], tru
|
||||
$isSchemajsonEmpty = empty(trim($template['schemajson']));
|
||||
|
||||
// Recupera i campi dalla tabella template_mapping
|
||||
$stmt = $pdo->prepare("SELECT id, field_id, excel_column, is_manual, manual_default, data_type, is_required, default_value, has_list, length, decimals, min_value, max_value, default_curr_date, tablename, field_label, main_field FROM template_mapping WHERE template_id = ?");
|
||||
$stmt = $pdo->prepare("SELECT id, field_id, excel_column, is_manual, manual_default, data_type, is_required, default_value, has_list, length, decimals, min_value, max_value, default_curr_date, tablename, field_label, main_field, is_visible_import FROM template_mapping WHERE template_id = ?");
|
||||
$stmt->execute([$id]);
|
||||
$mappings = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -83,8 +83,10 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
}
|
||||
|
||||
#schemaFieldsTable th:first-child,
|
||||
#schemaFieldsTable td:first-child {
|
||||
width: 50px;
|
||||
#schemaFieldsTable td:first-child,
|
||||
#schemaFieldsTable th:nth-child(2),
|
||||
#schemaFieldsTable td:nth-child(2) {
|
||||
width: 100px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
@@ -137,8 +139,8 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Main</th>
|
||||
<th>Visible on Import</th>
|
||||
<th>Title</th>
|
||||
<th>ID</th>
|
||||
<th>Type</th>
|
||||
<th>Mapping</th>
|
||||
<th>Default Value</th>
|
||||
@@ -150,8 +152,15 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
<td>
|
||||
<input type="checkbox" class="main-field-checkbox" data-mapping-id="<?php echo $mapping['id']; ?>" <?php echo $mapping['main_field'] == 1 ? 'checked' : ''; ?>>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($mapping['field_label'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($mapping['field_id'] ?? 'N/A'); ?></td>
|
||||
<td>
|
||||
<input type="checkbox" class="visible-import-checkbox" data-mapping-id="<?php echo $mapping['id']; ?>" <?php echo (isset($mapping['is_visible_import']) ? $mapping['is_visible_import'] : 1) == 1 ? 'checked' : ''; ?>>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo htmlspecialchars($mapping['field_label'] ?? 'N/A'); ?>
|
||||
<?php if ($mapping['is_required'] == 1): ?>
|
||||
<span class="badge bg-danger ms-2">Required</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($mapping['data_type'] ?? 'N/A'); ?></td>
|
||||
<td>
|
||||
<?php
|
||||
@@ -428,7 +437,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
|
||||
async function updateSchemaDetails() {
|
||||
if (!schemaId) {
|
||||
document.getElementById('schemaFieldsBody').innerHTML = '<tr><td colspan="6" class="text-warning">No schema associated.</td></tr>'; // Aggiornato colspan a 6
|
||||
document.getElementById('schemaFieldsBody').innerHTML = '<tr><td colspan="6" class="text-warning">No schema associated.</td></tr>';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -445,7 +454,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
await saveSchemaJson(templateId, JSON.stringify(data));
|
||||
alert('Schema updated successfully. Refresh the page to see changes.');
|
||||
} catch (error) {
|
||||
document.getElementById('schemaFieldsBody').innerHTML = '<tr><td colspan="6" class="text-danger">Error: ' + error.message + '</td></tr>'; // Aggiornato colspan a 6
|
||||
document.getElementById('schemaFieldsBody').innerHTML = '<tr><td colspan="6" class="text-danger">Error: ' + error.message + '</td></tr>';
|
||||
} finally {
|
||||
updateSchemaButton.disabled = false;
|
||||
updateSchemaButton.textContent = 'Update Schema Details';
|
||||
@@ -524,16 +533,11 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
console.error("❌ Error updating main_field:", data.message);
|
||||
// Revert checkbox state on error
|
||||
checkbox.checked = !checkbox.checked;
|
||||
// Riselezione visiva degli altri se errore
|
||||
if (value === 1) {
|
||||
document.querySelectorAll('.main-field-checkbox').forEach(cb => {
|
||||
cb.checked = cb.dataset.originalChecked === 'true';
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Aggiorna lo stato originale dopo successo
|
||||
document.querySelectorAll('.main-field-checkbox').forEach(cb => {
|
||||
cb.dataset.originalChecked = cb.checked;
|
||||
});
|
||||
@@ -542,12 +546,36 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
.catch(error => {
|
||||
console.error("❌ Fetch error:", error);
|
||||
checkbox.checked = !checkbox.checked;
|
||||
// Riselezione visiva degli altri se errore
|
||||
if (value === 1) {
|
||||
document.querySelectorAll('.main-field-checkbox').forEach(cb => {
|
||||
cb.checked = cb.dataset.originalChecked === 'true';
|
||||
});
|
||||
});
|
||||
} else if (event.target.classList.contains('visible-import-checkbox')) {
|
||||
const checkbox = event.target;
|
||||
const mappingId = checkbox.dataset.mappingId;
|
||||
const value = checkbox.checked ? 1 : 0;
|
||||
|
||||
fetch('update_visible_import.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
template_id: <?php echo $id; ?>,
|
||||
mapping_id: mappingId,
|
||||
value: value
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
console.error("❌ Error updating is_visible_import:", data.message);
|
||||
checkbox.checked = !checkbox.checked;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("❌ Fetch error:", error);
|
||||
checkbox.checked = !checkbox.checked;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -569,7 +597,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
mappedColumn = document.createElement('span');
|
||||
mappedColumn.className = 'mapped-column';
|
||||
mappedColumn.style.marginLeft = '5px';
|
||||
tr.querySelector('td:nth-child(5)').appendChild(mappedColumn); // Aggiornato a nth-child(5) per la nuova colonna
|
||||
tr.querySelector('td:nth-child(5)').appendChild(mappedColumn);
|
||||
}
|
||||
if (!removeBtn) {
|
||||
removeBtn = document.createElement('button');
|
||||
@@ -577,7 +605,7 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
|
||||
removeBtn.textContent = 'X';
|
||||
removeBtn.style.marginLeft = '5px';
|
||||
removeBtn.setAttribute('data-id', mappingId);
|
||||
tr.querySelector('td:nth-child(5)').appendChild(removeBtn); // Aggiornato a nth-child(5)
|
||||
tr.querySelector('td:nth-child(5)').appendChild(removeBtn);
|
||||
|
||||
removeBtn.addEventListener('click', function(e) {
|
||||
let tr = e.target.closest('tr');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
<!-- Modal modificato con pulsante per riconoscimento vocale e download -->
|
||||
<div class="modal fade" id="partsModal" tabindex="-1" aria-labelledby="partsModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" style="max-width: 80% !important; width: 80% !important;">
|
||||
<div class="modal-content">
|
||||
@@ -8,7 +9,15 @@
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h6>Elenco Parti</h6>
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
|
||||
<h6 style="margin: 0; white-space: nowrap;">Elenco Parti</h6>
|
||||
<div style="display: flex; align-items: center;">
|
||||
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px;">
|
||||
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
||||
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rinumera Parti</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm ms-2" id="toggleVoiceBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;"><i class="fas fa-microphone"></i> Voce</button>
|
||||
</div>
|
||||
</div>
|
||||
<ul id="partsList" class="list-group"></ul>
|
||||
<table class="table table-striped table-sm mt-3" id="partsTable">
|
||||
<thead>
|
||||
@@ -35,13 +44,14 @@
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h6>Foto del Campione</h6>
|
||||
<div id="photoSelectorContainer" style="display: none;">
|
||||
<!-- Dropdown or buttons for photo selection will appear here -->
|
||||
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
||||
<button type="button" class="btn btn-primary btn-sm" id="downloadPhotoBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem; margin-right: 10px;"><i class="fas fa-download"></i> </button>
|
||||
<div id="photoSelectorContainer" style="display: none;"></div>
|
||||
</div>
|
||||
<div style="position: relative; width: 100%; min-height: 400px;">
|
||||
<img id="samplePhoto" src="" alt="Foto del campione" style="max-width: 100%; max-height: 100%; object-fit: contain; position: absolute; top: 0; left: 0;">
|
||||
<canvas id="photoCanvas" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></canvas>
|
||||
<div id="descriptionList" class="draggable-description" style="display: none;"></div>
|
||||
<canvas id="overlayCanvas" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000;"></canvas> <!-- Nuovo canvas per Fabric.js -->
|
||||
<div id="markerContainer"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,8 +59,8 @@
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary btn-sm" id="addDescriptionsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Aggiungi Lista Descrizioni</button>
|
||||
<button type="button" class="btn btn-warning btn-sm" id="removeBackgroundBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rimuovi Sfondo</button>
|
||||
<button type="button" class="btn btn-danger btn-sm" id="removeAnnotationsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rimuovi Annotazioni</button>
|
||||
<button type="button" class="btn btn-danger btn-sm" id="removeAnnotationsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Rimuovi Descrizioni</button>
|
||||
<button type="button" class="btn btn-warning btn-sm" id="undoMarkerBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Undo Marker</button>
|
||||
<button type="button" class="btn btn-success btn-sm" id="savePhotoBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Salva Foto con Nome</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">Chiudi</button>
|
||||
</div>
|
||||
@@ -88,6 +98,14 @@
|
||||
font-size: 0.6rem !important;
|
||||
}
|
||||
|
||||
#partsModal {
|
||||
z-index: 1060 !important;
|
||||
}
|
||||
|
||||
#partsModal .modal-backdrop {
|
||||
z-index: 1055 !important;
|
||||
}
|
||||
|
||||
#partsModal .modal-content {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
@@ -99,30 +117,58 @@
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
#partsList .list-group-item:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
#partsList input[type="color"] {
|
||||
width: 30px;
|
||||
height: 24px;
|
||||
padding: 0;
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.draggable-description {
|
||||
position: absolute;
|
||||
background: rgba(255, 255, 255, 0.8);
|
||||
padding: 5px;
|
||||
font-size: 10px;
|
||||
font-family: Arial, sans-serif;
|
||||
color: #000000;
|
||||
cursor: move;
|
||||
user-select: none;
|
||||
z-index: 1000;
|
||||
min-width: 100px;
|
||||
min-height: 50px;
|
||||
overflow: visible;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.draggable-description.active-interaction {
|
||||
border: 2px dashed #000;
|
||||
}
|
||||
|
||||
.draggable-description div {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.resize-handle {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: #888;
|
||||
cursor: se-resize;
|
||||
}
|
||||
|
||||
.draggable-marker {
|
||||
position: absolute;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: rgba(255, 0, 0, 0.5);
|
||||
border: 1px solid #ff0000;
|
||||
border-radius: 50%;
|
||||
color: #ffffff;
|
||||
text-align: center;
|
||||
@@ -146,12 +192,10 @@
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
/* Normale Save button */
|
||||
#savePhotoBtn {
|
||||
transition: all 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
/* Modifiche non salvate */
|
||||
#savePhotoBtn.unsaved {
|
||||
background-color: #dc3545 !important;
|
||||
border-color: #dc3545 !important;
|
||||
@@ -159,7 +203,6 @@
|
||||
animation: pulse 1.2s infinite;
|
||||
}
|
||||
|
||||
/* Animazione di pulsazione */
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
|
||||
@@ -173,4 +216,37 @@
|
||||
box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
|
||||
}
|
||||
}
|
||||
|
||||
.color-picker-container {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.color-picker {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 25px;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px;
|
||||
z-index: 1002;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
||||
flex-wrap: wrap;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.color-option {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
margin: 3px;
|
||||
border: 1px solid #000;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.color-option:hover {
|
||||
border: 2px solid #000;
|
||||
margin: 2px;
|
||||
}
|
||||
</style>
|
||||
+1157
-401
File diff suppressed because it is too large
Load Diff
+710
-107
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,12 @@
|
||||
<?php
|
||||
// photos_popup.php
|
||||
include('include/headscript.php');
|
||||
// Includi Fabric.js solo per questa pagina
|
||||
?>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/5.3.1/fabric.min.js"></script>
|
||||
|
||||
<?php
|
||||
// Includi l'autoloader di Composer
|
||||
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
@@ -11,70 +17,131 @@ use Endroid\QrCode\QrCode;
|
||||
use Endroid\QrCode\RoundBlockSizeMode;
|
||||
use Endroid\QrCode\Writer\PngWriter;
|
||||
|
||||
// Abilita logging per debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/photos_popup_debug.log');
|
||||
|
||||
// Log iniziale
|
||||
error_log("Richiesta a photos_popup.php: " . print_r($_GET, true));
|
||||
|
||||
// Carica le variabili d'ambiente
|
||||
try {
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/../../');
|
||||
$dotenv->load();
|
||||
error_log("File .env caricato correttamente da " . __DIR__ . '/../../.env');
|
||||
} catch (Exception $e) {
|
||||
error_log("Errore nel caricamento del file .env: " . $e->getMessage());
|
||||
echo json_encode(['error' => 'Errore nel caricamento del file di configurazione']);
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: Impossibile caricare il file di configurazione.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica che BASE_URL sia definito
|
||||
if (!isset($_ENV['BASE_URL'])) {
|
||||
error_log("Errore: la variabile BASE_URL non è definita nel file .env");
|
||||
echo json_encode(['error' => 'Variabile BASE_URL non definita']);
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: Variabile BASE_URL non definita.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Verifica che l'iddatadb sia stato passato
|
||||
if (!isset($_GET['iddatadb']) || empty($_GET['iddatadb'])) {
|
||||
echo json_encode(['error' => 'ID riga non fornito']);
|
||||
// Verifica che almeno uno degli ID sia passato
|
||||
$iddatadb = isset($_GET['iddatadb']) && !empty($_GET['iddatadb']) ? intval($_GET['iddatadb']) : null;
|
||||
$idquotations = isset($_GET['idquotations']) && !empty($_GET['idquotations']) ? intval($_GET['idquotations']) : null;
|
||||
|
||||
if (!$iddatadb && !$idquotations) {
|
||||
error_log("Errore: ID riga o ID quotations non fornito");
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: ID riga o ID quotations non fornito.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$iddatadb = intval($_GET['iddatadb']);
|
||||
|
||||
// Recupera i dettagli della riga (idriga e sample_code)
|
||||
$stmt = $pdo->prepare("SELECT iddatadb, sample_code FROM datadb WHERE iddatadb = ?");
|
||||
$stmt->execute([$iddatadb]);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$row) {
|
||||
echo json_encode(['error' => 'Riga non trovata']);
|
||||
if ($iddatadb && $idquotations) {
|
||||
error_log("Errore: Non è possibile specificare sia iddatadb che idquotations");
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: Non è possibile specificare sia iddatadb che idquotations.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$idriga = $row['iddatadb'];
|
||||
$sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||
// Determina quale ID e tabella usare
|
||||
$paramName = $iddatadb ? 'iddatadb' : 'id'; // Usa 'id' per quotations
|
||||
$paramValue = $iddatadb ?: $idquotations;
|
||||
$table = $iddatadb ? 'datadb' : 'quotations';
|
||||
$field = $iddatadb ? 'sample_code' : 'description'; // Usa 'description' per quotations
|
||||
$photoTable = 'datadb_photos'; // Usa sempre datadb_photos
|
||||
$photoParamName = $iddatadb ? 'iddatadb' : 'idquotations'; // Usa 'idquotations' per datadb_photos
|
||||
|
||||
// Recupera i dettagli della riga
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT {$paramName}, {$field} FROM {$table} WHERE {$paramName} = ?");
|
||||
$stmt->execute([$paramValue]);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$row) {
|
||||
error_log("Errore: Riga non trovata per {$paramName} = {$paramValue}");
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: Riga non trovata.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
error_log("Errore query dettagli riga: " . $e->getMessage());
|
||||
?>
|
||||
<div class="popup-content">
|
||||
<p>Errore: Impossibile recuperare i dettagli della riga.</p>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = $row[$paramName];
|
||||
$code = $row[$field] ?? 'Non disponibile';
|
||||
|
||||
// Recupera le foto associate alla riga
|
||||
$stmt = $pdo->prepare("SELECT id, file_path, file_name, description, uploaded_at FROM datadb_photos WHERE iddatadb = ? ORDER BY uploaded_at DESC");
|
||||
$stmt->execute([$iddatadb]);
|
||||
$photos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
try {
|
||||
$stmt = $pdo->prepare("SELECT id, file_path, file_name, description, uploaded_at FROM {$photoTable} WHERE {$photoParamName} = ? ORDER BY uploaded_at DESC");
|
||||
$stmt->execute([$paramValue]);
|
||||
$photos = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (Exception $e) {
|
||||
error_log("Errore query foto: " . $e->getMessage());
|
||||
$photos = []; // Imposta array vuoto in caso di errore
|
||||
}
|
||||
|
||||
// Definisci il percorso base per le foto
|
||||
$photoBasePath = '../photostrf/';
|
||||
|
||||
// Usa la variabile d'ambiente BASE_URL
|
||||
$baseUrl = rtrim($_ENV['BASE_URL'], '/'); // Rimuove eventuali slash finali
|
||||
$uploadUrl = $baseUrl . "/upload_photos_mobile.php?iddatadb=" . $iddatadb;
|
||||
$baseUrl = rtrim($_ENV['BASE_URL'], '/');
|
||||
$uploadUrl = $iddatadb
|
||||
? $baseUrl . "/upload_photos_mobile.php?iddatadb=" . $iddatadb
|
||||
: $baseUrl . "/upload_photos_mobile.php?idquotations=" . $idquotations;
|
||||
|
||||
// Genera il QR code con endroid/qr-code 6.0.6
|
||||
$qrCodeDir = '../photostrf/qrcodes/';
|
||||
if (!is_dir($qrCodeDir)) {
|
||||
mkdir($qrCodeDir, 0755, true);
|
||||
}
|
||||
$qrCodeFile = $qrCodeDir . "qrcode_{$iddatadb}.png";
|
||||
$qrCodeFile = $qrCodeDir . "qrcode_{$id}.png";
|
||||
|
||||
$writer = new PngWriter();
|
||||
|
||||
// Crea il QR code usando il costruttore
|
||||
$qrCode = new QrCode(
|
||||
data: $uploadUrl,
|
||||
encoding: new Encoding('UTF-8'),
|
||||
@@ -98,13 +165,13 @@ $result->saveToFile($qrCodeFile);
|
||||
</div>
|
||||
</div>
|
||||
<h3>Manage Photos</h3>
|
||||
<p><strong>ID Row:</strong> <?= htmlspecialchars($idriga) ?></p>
|
||||
<p><strong>Sample Code:</strong> <?= htmlspecialchars($sampleCode) ?></p>
|
||||
<p><strong>ID:</strong> <?= htmlspecialchars($id) ?></p>
|
||||
<p><strong>Code:</strong> <?= htmlspecialchars($code) ?></p>
|
||||
|
||||
<!-- QR Code per il caricamento da mobile -->
|
||||
<div style="text-align: center; margin-bottom: 20px;">
|
||||
<p>Scan the QR Code with the mobile to take photo with camera:</p>
|
||||
<img src="../photostrf/qrcodes/qrcode_<?= $iddatadb ?>.png" alt="QR Code" style="max-width: 150px;">
|
||||
<img src="../photostrf/qrcodes/qrcode_<?= htmlspecialchars($id) ?>.png" alt="QR Code" style="max-width: 150px;">
|
||||
<p style="margin-top: 10px;">
|
||||
<a href="<?= htmlspecialchars($uploadUrl) ?>" target="_blank"><?= htmlspecialchars($uploadUrl) ?></a>
|
||||
</p>
|
||||
@@ -116,7 +183,6 @@ $result->saveToFile($qrCodeFile);
|
||||
<input type="file" id="photoInput" multiple accept="image/*" style="display: none;">
|
||||
</div>
|
||||
<!-- Area per la webcam -->
|
||||
<!-- Area per la webcam -->
|
||||
<div id="webcamArea" style="display: none; text-align: center; margin-bottom: 20px;">
|
||||
<p>Webcam Preview</p>
|
||||
<select id="webcamSelect" style="margin-bottom: 10px; padding: 5px;">
|
||||
@@ -128,10 +194,11 @@ $result->saveToFile($qrCodeFile);
|
||||
<button id="closeWebcamBtn" style="padding: 10px 20px; background: #dc3545; color: white; border: none; cursor: pointer;">Close Webcam</button>
|
||||
</div>
|
||||
</div>
|
||||
<button id="openWebcamBtn" style="padding: 10px 20px; background: #007bff; color: white; border: none; cursor: pointer; margin-bottom: 20px;">Take Photo with Webcam</button> <!-- Elenco delle foto -->
|
||||
<button id="openWebcamBtn" style="padding: 10px 20px; background: #007bff; color: white; border: none; cursor: pointer; margin-bottom: 20px;">Take Photo with Webcam</button>
|
||||
<!-- Elenco delle foto -->
|
||||
<div id="photosList">
|
||||
<?php if (empty($photos)): ?>
|
||||
<p>No Photos present.</p>
|
||||
<p>Nessuna foto presente.</p>
|
||||
<?php else: ?>
|
||||
<?php foreach ($photos as $photo): ?>
|
||||
<?php
|
||||
@@ -156,6 +223,8 @@ $result->saveToFile($qrCodeFile);
|
||||
</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
<!-- Bottone Crea Collage -->
|
||||
<button id="createCollageBtn" style="padding: 10px 20px; background: #ffc107; color: white; border: none; cursor: pointer; margin-top: 20px;">Crea Collage</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
@@ -164,6 +233,52 @@ $result->saveToFile($qrCodeFile);
|
||||
<span class="image-modal-close">×</span>
|
||||
<img id="enlargedImage" class="image-modal-content" src="" alt="Immagine ingrandita">
|
||||
</div>
|
||||
|
||||
<!-- Modale per collage -->
|
||||
<div id="collageModal" class="modal" style="display: none; position: fixed; z-index: 1002; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.8);">
|
||||
<div class="modal-content" style="background: white; margin: 5% auto; padding: 20px; width: 80%; max-width: 1200px; position: relative;">
|
||||
<span class="close-collage" style="position: absolute; top: 10px; right: 20px; font-size: 30px; font-weight: bold; color: #333; cursor: pointer; z-index: 1003; background: #fff; padding: 5px 10px; border-radius: 50%;">×</span>
|
||||
<h3>Crea Collage</h3>
|
||||
|
||||
<!-- Lista foto selezionabili -->
|
||||
<div id="collagePhotoList" style="max-height: 200px; overflow-y: auto; margin-bottom: 20px;">
|
||||
<?php foreach ($photos as $photo): ?>
|
||||
<div style="display: inline-block; margin: 10px;">
|
||||
<input type="checkbox" class="photo-checkbox" data-path="../photostrf/<?= htmlspecialchars($photo['file_path']) ?>">
|
||||
<img src="../photostrf/<?= htmlspecialchars($photo['file_path']) ?>" alt="" style="width: 80px; height: 80px;">
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<!-- Bottone per aggiungere selezionate al canvas -->
|
||||
<button id="addToCanvasBtn">Aggiungi Selezionate al Canvas</button>
|
||||
|
||||
<!-- Canvas per editing -->
|
||||
<canvas id="collageCanvas" width="960" height="720" style="border: 1px solid #ccc; margin-top: 20px;"></canvas>
|
||||
|
||||
<!-- Pannello dei livelli -->
|
||||
<div id="layersPanel" style="width: 120px; max-height: 600px; overflow-y: auto; background: #f8f9fa; padding: 10px; position: absolute; right: 0; top: 60px;">
|
||||
<h4 style="margin: 0 0 10px 0; font-size: 16px;">Livelli</h4>
|
||||
<ul id="layersList" style="list-style: none; padding: 0;"></ul>
|
||||
</div>
|
||||
|
||||
<!-- Bottoni azioni -->
|
||||
<div style="margin-top: 20px; display: flex; flex-wrap: wrap; gap: 5px;">
|
||||
<button id="saveCollageBtn" title="Salva il collage"><i class="fas fa-save"></i></button>
|
||||
<button id="bringToFrontBtn" title="Porta in primo piano"><i class="fas fa-arrow-up"></i></button>
|
||||
<button id="sendToBackBtn" title="Manda in fondo"><i class="fas fa-arrow-down"></i></button>
|
||||
<button id="bringForwardBtn" title="Sposta avanti di un livello"><i class="fas fa-arrow-circle-up"></i></button>
|
||||
<button id="sendBackwardBtn" title="Sposta indietro di un livello"><i class="fas fa-arrow-circle-down"></i></button>
|
||||
<button id="cropImageBtn" title="Ritaglia immagine selezionata" disabled><i class="fas fa-crop"></i></button>
|
||||
<button id="applyCropBtn" title="Applica ritaglio" disabled><i class="fas fa-crop"></i> Applica</button>
|
||||
<button id="cancelCropBtn" title="Annulla ritaglio" disabled><i class="fas fa-crop"></i> Annulla</button>
|
||||
<button id="removeBackgroundBtn" title="Rimuovi sfondo immagine selezionata" disabled><i class="fas fa-eraser"></i> Rimuovi Sfondo</button>
|
||||
<button id="removeImageBtn" title="Rimuovi immagine selezionata" disabled><i class="fas fa-trash-alt"></i> Rimuovi</button>
|
||||
<button id="undoBtn" title="Annulla ultima azione" disabled><i class="fas fa-undo"></i></button>
|
||||
<p id="backgroundRemovalInstruction" style="display: none; color: #007bff;">Clicca sull'immagine per selezionare il colore dello sfondo da rimuovere</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@@ -243,4 +358,71 @@ $result->saveToFile($qrCodeFile);
|
||||
font-size: 16px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Stile per i pulsanti del modale collage */
|
||||
#collageModal button {
|
||||
padding: 8px 12px;
|
||||
margin: 5px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#saveCollageBtn {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#bringToFrontBtn,
|
||||
#sendToBackBtn,
|
||||
#bringForwardBtn,
|
||||
#sendBackwardBtn {
|
||||
background: #007bff;
|
||||
color: white;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#cropImageBtn,
|
||||
#applyCropBtn,
|
||||
#cancelCropBtn,
|
||||
#removeBackgroundBtn,
|
||||
#removeImageBtn,
|
||||
#undoBtn {
|
||||
background: #ffc107;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#collageModal button:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#collageModal button i {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
/* Stile per il pannello dei livelli */
|
||||
#layersPanel {
|
||||
z-index: 1002;
|
||||
}
|
||||
|
||||
#layersPanel li {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
#layersPanel img {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border: 2px solid #ccc;
|
||||
cursor: pointer;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
#layersPanel img:hover {
|
||||
border-color: #007bff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,429 @@
|
||||
<?php
|
||||
// Abilita errori per debug
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/quotations_debug.log');
|
||||
if (!file_exists(__DIR__ . '/quotations_debug.log')) {
|
||||
file_put_contents(__DIR__ . '/quotations_debug.log', "Inizio operazioni alle " . date('Y-m-d H:i:s') . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
// Log iniziale
|
||||
error_log("Inizio operazioni alle " . date('Y-m-d H:i:s'));
|
||||
|
||||
include('include/headscript.php');
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Recupera l'ID dell'utente loggato
|
||||
$user_id = $iduserlogin ?? 1;
|
||||
|
||||
// Gestione creazione nuova quotation (crea record vuoto su conferma)
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'create') {
|
||||
$description = '';
|
||||
$customer = '';
|
||||
|
||||
$stmt = $pdo->prepare("INSERT INTO quotations (description, customer, iduser) VALUES (?, ?, ?)");
|
||||
$stmt->execute([$description, $customer, $user_id]);
|
||||
$newId = $pdo->lastInsertId();
|
||||
|
||||
// Log creazione
|
||||
error_log("Creata nuova quotation ID: $newId");
|
||||
|
||||
// Reindirizza alla modifica della nuova quotation
|
||||
header("Location: quotations.php?edit_id=" . $newId . "&status=success&message=" . urlencode("Quotation creata con successo"));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Gestione modifica quotation
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update' && isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
$description = $_POST['description'] ?? '';
|
||||
$customer = $_POST['customer'] ?? '';
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE quotations SET description = ?, customer = ? WHERE id = ? AND iduser = ?");
|
||||
$stmt->execute([$description, $customer, $id, $user_id]);
|
||||
|
||||
// Log modifica
|
||||
error_log("Modificata quotation ID: $id");
|
||||
|
||||
// Reindirizza alla lista delle quotations
|
||||
header("Location: quotations.php?status=success&message=" . urlencode("Quotation modificata con successo"));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Gestione cancellazione quotation
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'delete' && isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']);
|
||||
|
||||
$stmt = $pdo->prepare("DELETE FROM quotations WHERE id = ? AND iduser = ?");
|
||||
$stmt->execute([$id, $user_id]);
|
||||
|
||||
// Log cancellazione
|
||||
error_log("Cancellata quotation ID: $id");
|
||||
|
||||
header("Location: quotations.php?status=success&message=" . urlencode("Quotation cancellata con successo"));
|
||||
exit;
|
||||
}
|
||||
|
||||
// Recupera tutte le quotations per l'utente
|
||||
$stmt = $pdo->prepare("SELECT * FROM quotations WHERE iduser = ? ORDER BY creation_date DESC");
|
||||
$stmt->execute([$user_id]);
|
||||
$quotations = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
// Verifica se è richiesta la modifica di una quotation
|
||||
$editQuotation = null;
|
||||
if (isset($_GET['edit_id'])) {
|
||||
$editId = intval($_GET['edit_id']);
|
||||
$stmt = $pdo->prepare("SELECT * FROM quotations WHERE id = ? AND iduser = ?");
|
||||
$stmt->execute([$editId, $user_id]);
|
||||
$editQuotation = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
}
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" href="assets/images/favicon-32x32.png" type="image/png" />
|
||||
<?php include('cssinclude.php'); ?>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2Lw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.4/css/jquery.dataTables.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/5.3.1/fabric.min.js"></script>
|
||||
<style>
|
||||
/* Stili simili alla pagina fornita, adattati */
|
||||
.cell-changed {
|
||||
background-color: #fff3b0 !important;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
input.manual-input,
|
||||
select.manual-input {
|
||||
background-color: #fff3cd;
|
||||
}
|
||||
|
||||
input.required-input,
|
||||
select.required-input {
|
||||
background-color: #f8d7da;
|
||||
}
|
||||
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ced4da;
|
||||
border-radius: 4px;
|
||||
padding: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
padding: 6px 8px;
|
||||
margin-right: 5px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
width: 35px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background-color: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
background-color: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.photos-btn {
|
||||
background-color: #007bff;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.parts-btn {
|
||||
background-color: #ffc107;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-group textarea {
|
||||
height: 100px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.flash-success {
|
||||
background-color: #d4edda !important;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.quotation-actions {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1050;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: auto;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: #fefefe;
|
||||
margin: 15% auto;
|
||||
padding: 20px;
|
||||
border: 1px solid #888;
|
||||
width: 80%;
|
||||
max-width: 600px;
|
||||
border-radius: 8px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
color: #aaa;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close-btn:hover,
|
||||
.close-btn:focus {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<title>Gestione Quotations - <?= htmlspecialchars($titlewebsite, ENT_QUOTES, 'UTF-8'); ?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<?php include('include/navbar.php'); ?>
|
||||
<?php include('include/topbar.php'); ?>
|
||||
<div class="page-wrapper">
|
||||
<div class="page-content">
|
||||
<div class="card radius-10">
|
||||
<div class="card-header">
|
||||
<div class="d-flex align-items-center">
|
||||
<div>
|
||||
<h6 class="mb-0">Gestione Quotations</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<?php if ($editQuotation): ?>
|
||||
<!-- Modifica Quotation -->
|
||||
<h6 class="mb-3">Modifica Quotation ID: <?= $editQuotation['id'] ?></h6>
|
||||
<form id="editForm" method="post">
|
||||
<input type="hidden" name="action" value="update">
|
||||
<input type="hidden" name="id" value="<?= $editQuotation['id'] ?>">
|
||||
<div class="form-group">
|
||||
<label for="description">Descrizione</label>
|
||||
<textarea id="description" name="description" class="manual-input required-input" required><?= htmlspecialchars($editQuotation['description']) ?></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="customer">Cliente</label>
|
||||
<input type="text" id="customer" name="customer" class="manual-input required-input" value="<?= htmlspecialchars($editQuotation['customer']) ?>" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Salva Modifiche</button>
|
||||
<a href="quotations.php" class="btn btn-secondary">Torna alla Lista</a>
|
||||
</form>
|
||||
<div class="quotation-actions">
|
||||
<h6 class="mb-3">Azioni</h6>
|
||||
<button type="button" class="photos-btn action-btn" data-row="<?= $index ?>" data-idquotations="<?= $editQuotation['id'] ?>" style="background: #007bff; color: white; border: none; padding: 8px 12px; border-radius: 5px; cursor: pointer; flex: 1;"><i class="fas fa-camera"></i></button>
|
||||
<button class="parts-btn" data-iddatadb="" data-idquotations="456" data-row="0">Parti</button>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<!-- Lista Quotations -->
|
||||
<div class="mb-3">
|
||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#createModal">Crea Nuova Quotation</button>
|
||||
</div>
|
||||
<h6 class="mb-3">Quotations Esistenti</h6>
|
||||
<table id="quotationsTable" class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Data Creazione</th>
|
||||
<th>Descrizione</th>
|
||||
<th>Cliente</th>
|
||||
<th>Azioni</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($quotations as $row): ?>
|
||||
<tr data-id="<?= $row['id'] ?>">
|
||||
<td><?= htmlspecialchars($row['id']) ?></td>
|
||||
<td><?= htmlspecialchars($row['creation_date']) ?></td>
|
||||
<td>
|
||||
<textarea name="description" class="cell-input manual-input form-control"><?= htmlspecialchars($row['description']) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="customer" class="cell-input manual-input form-control" value="<?= htmlspecialchars($row['customer']) ?>">
|
||||
</td>
|
||||
<!-- In quotations.php, nella tabella delle quotations -->
|
||||
<td>
|
||||
<button type="button" class="save-btn action-btn edit-btn" data-id="<?= $row['id'] ?>" title="Salva Modifiche"><i class="fas fa-save"></i></button>
|
||||
<button type="button" class="delete-btn action-btn" data-id="<?= $row['id'] ?>" title="Cancella" data-bs-toggle="modal" data-bs-target="#deleteModal"><i class="fas fa-trash"></i></button>
|
||||
<button type="button" class="photos-btn action-btn" data-entity-type="quotation" data-idquotations="<?= $row['id'] ?>" title="Photos"><i class="fas fa-camera"></i></button>
|
||||
<button type="button" class="parts-btn action-btn" data-entity-type="quotation" data-idquotations="<?= $row['id'] ?>" title="Parts"><i class="fas fa-puzzle-piece"></i></button>
|
||||
<a href="quotations.php?edit_id=<?= $row['id'] ?>" class="btn btn-secondary action-btn" title="Modifica Dettagliata"><i class="fas fa-edit"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal per conferma creazione nuova quotation -->
|
||||
<div class="modal fade" id="createModal" tabindex="-1" aria-labelledby="createModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="createModalLabel">Conferma Creazione Nuova Quotation</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Vuoi creare una nuova quotation?</p>
|
||||
<form id="createModalForm" method="post">
|
||||
<input type="hidden" name="action" value="create">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annulla</button>
|
||||
<button type="button" class="btn btn-primary" id="confirmCreate">Conferma</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Modal per conferma cancellazione -->
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">Conferma Cancellazione</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Sicuro di voler cancellare questa quotation?</p>
|
||||
<form id="deleteForm" method="post">
|
||||
<input type="hidden" name="action" value="delete">
|
||||
<input type="hidden" name="id" id="deleteQuotationId">
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Annulla</button>
|
||||
<button type="button" class="btn btn-danger" id="confirmDelete">Conferma</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overlay toggle-icon"></div>
|
||||
<a href="javaScript:;" class="back-to-top"><i class='bx bxs-up-arrow-alt'></i></a>
|
||||
<?php include('include/footer.php'); ?>
|
||||
</div>
|
||||
<?php include('modal_parts.php'); ?>
|
||||
<?php include('photos_functions.php'); ?>
|
||||
<?php include('jsinclude.php'); ?>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.13.4/js/jquery.dataTables.min.js"></script>
|
||||
<script src="photos.js"></script>
|
||||
<script src="parts.js"></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// Inizializza DataTables se non siamo in modalità modifica
|
||||
if (!document.querySelector('#editForm')) {
|
||||
$('#quotationsTable').DataTable({
|
||||
"paging": true,
|
||||
"searching": true,
|
||||
"ordering": true,
|
||||
"info": true,
|
||||
"autoWidth": false,
|
||||
"responsive": true
|
||||
});
|
||||
}
|
||||
|
||||
// Gestione conferma creazione nel modal
|
||||
document.getElementById('confirmCreate').addEventListener('click', function() {
|
||||
document.getElementById('createModalForm').submit();
|
||||
});
|
||||
|
||||
// Gestione modifica inline e save nella lista
|
||||
document.querySelectorAll('.edit-btn').forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
const row = this.closest('tr');
|
||||
const id = row.dataset.id;
|
||||
const description = row.querySelector('textarea[name="description"]').value;
|
||||
const customer = row.querySelector('input[name="customer"]').value;
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('action', 'update');
|
||||
formData.append('id', id);
|
||||
formData.append('description', description);
|
||||
formData.append('customer', customer);
|
||||
|
||||
fetch('quotations.php', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}).then(response => {
|
||||
if (response.ok) {
|
||||
row.classList.add('flash-success');
|
||||
setTimeout(() => row.classList.remove('flash-success'), 500);
|
||||
alert('Quotation modificata con successo!');
|
||||
} else {
|
||||
alert('Errore durante la modifica.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Gestione apertura modal di cancellazione
|
||||
document.querySelectorAll('.delete-btn').forEach(btn => {
|
||||
btn.addEventListener('click', function() {
|
||||
const id = this.dataset.id;
|
||||
document.getElementById('deleteQuotationId').value = id;
|
||||
});
|
||||
});
|
||||
|
||||
// Gestione conferma cancellazione nel modal
|
||||
document.getElementById('confirmDelete').addEventListener('click', function() {
|
||||
document.getElementById('deleteForm').submit();
|
||||
});
|
||||
|
||||
// I bottoni photos e parts usano gli script esistenti (photos.js, parts.js), passando data-idquotations
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Modale per le foto in quotations.php -->
|
||||
<div class="modal" id="photosModal">
|
||||
<div class="modal-content">
|
||||
<span class="close-btn">×</span>
|
||||
<div class="popup-content"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$photo_path = $_POST['photo_path'] ?? '';
|
||||
$iddatadb = $_POST['iddatadb'] ?? '';
|
||||
|
||||
if (empty($photo_path) || empty($iddatadb)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Parametri mancanti']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica che il file esista
|
||||
$full_path = realpath($photo_path);
|
||||
if (!$full_path || !file_exists($full_path)) {
|
||||
echo json_encode(['success' => false, 'message' => 'File non trovato']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Configurazione Remove.bg API
|
||||
$api_key = 'YOUR_API_KEY'; // Inserisci la tua chiave API di Remove.bg
|
||||
$api_url = 'https://api.remove.bg/v1.0/removebg';
|
||||
|
||||
// Preparazione della richiesta
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $api_url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, [
|
||||
'image_file' => new CURLFile($full_path),
|
||||
'size' => 'auto',
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
'X-Api-Key: ' . $api_key
|
||||
]);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
// Esecuzione della richiesta
|
||||
$response = curl_exec($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
if ($http_code !== 200) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore API Remove.bg']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Salva l'immagine senza sfondo
|
||||
$timestamp = date('YmdHis');
|
||||
$new_filename = "no_bg_photo_{$iddatadb}_{$timestamp}.png";
|
||||
$new_filepath = "uploads/{$new_filename}"; // Assumi una directory Uploads/
|
||||
file_put_contents($new_filepath, $response);
|
||||
|
||||
// Aggiorna il database o il sistema di file con il nuovo percorso
|
||||
// Qui potresti aggiungere logica per aggiornare il database con il nuovo percorso
|
||||
|
||||
echo json_encode(['success' => true, 'new_photo_path' => $new_filepath]);
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$iddatadb = $data['iddatadb'] ?? null;
|
||||
$parts = $data['parts'] ?? [];
|
||||
|
||||
if (!$iddatadb || empty($parts)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Elimina tutte le parti esistenti per l'iddatadb per evitare conflitti di unicità
|
||||
$stmt = $pdo->prepare("DELETE FROM identification_parts WHERE iddatadb = :iddatadb");
|
||||
$stmt->execute([':iddatadb' => $iddatadb]);
|
||||
|
||||
// Prepara l'inserimento delle nuove parti
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO identification_parts
|
||||
(iddatadb, part_number, part_description, mix, created_at, updated_at)
|
||||
VALUES (:iddatadb, :part_number, :part_description, :mix, NOW(), NOW())
|
||||
");
|
||||
|
||||
$part_ids = [];
|
||||
foreach ($parts as $part) {
|
||||
$partNumber = $part['part_number'] ?? null;
|
||||
$partDescription = $part['part_description'] ?? '';
|
||||
$mix = $part['mix'] ?? 'N';
|
||||
|
||||
if (!$partNumber || !$partDescription) {
|
||||
throw new PDOException("Numero parte o descrizione mancante per parte: " . json_encode($part));
|
||||
}
|
||||
|
||||
$stmt->execute([
|
||||
':iddatadb' => $iddatadb,
|
||||
':part_number' => $partNumber,
|
||||
':part_description' => $partDescription,
|
||||
':mix' => $mix
|
||||
]);
|
||||
$part_ids[] = $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'part_ids' => $part_ids,
|
||||
'message' => 'Parti rinumerate con successo'
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Errore nel salvataggio: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$idquotations = $data['idquotations'] ?? null;
|
||||
$parts = $data['parts'] ?? [];
|
||||
|
||||
if (!$idquotations || empty($parts)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$pdo->beginTransaction();
|
||||
|
||||
// Elimina tutte le parti esistenti per idquotations
|
||||
$stmt = $pdo->prepare("DELETE FROM identification_parts WHERE idquotations = :idquotations");
|
||||
$stmt->execute([':idquotations' => $idquotations]);
|
||||
|
||||
// Prepara l'inserimento delle nuove parti
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO identification_parts
|
||||
(idquotations, part_number, part_description, mix, created_at, updated_at)
|
||||
VALUES (:idquotations, :part_number, :part_description, :mix, NOW(), NOW())
|
||||
");
|
||||
|
||||
$part_ids = [];
|
||||
foreach ($parts as $part) {
|
||||
$partNumber = $part['part_number'] ?? null;
|
||||
$partDescription = $part['part_description'] ?? '';
|
||||
$mix = $part['mix'] ?? 'N';
|
||||
|
||||
if (!$partNumber || !$partDescription) {
|
||||
throw new PDOException("Numero parte o descrizione mancante per parte: " . json_encode($part));
|
||||
}
|
||||
|
||||
$stmt->execute([
|
||||
':idquotations' => $idquotations,
|
||||
':part_number' => $partNumber,
|
||||
':part_description' => $partDescription,
|
||||
':mix' => $mix
|
||||
]);
|
||||
$part_ids[] = $pdo->lastInsertId();
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'part_ids' => $part_ids,
|
||||
'message' => 'Parti rinumerate con successo'
|
||||
]);
|
||||
} catch (PDOException $e) {
|
||||
$pdo->rollBack();
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Errore nel salvataggio: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
include('include/headscript.php');
|
||||
error_reporting(E_ALL);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
$dataURL = $_POST['dataURL'] ?? null;
|
||||
$filename = $_POST['filename'] ?? null;
|
||||
$idquotations = $_POST['idquotations'] ?? null;
|
||||
|
||||
if (!$dataURL || !$filename || !$idquotations) {
|
||||
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
// Verifica che idquotations esista nella tabella quotations
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
$stmt = $pdo->prepare("SELECT idquotations FROM quotations WHERE idquotations = :idquotations");
|
||||
$stmt->execute([':idquotations' => $idquotations]);
|
||||
if (!$stmt->fetch()) {
|
||||
echo json_encode(['success' => false, 'message' => 'idquotations non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Salva l'immagine
|
||||
$data = explode(',', $dataURL)[1];
|
||||
$decodedData = base64_decode($data);
|
||||
|
||||
$dirPath = '../photostrf/annotated';
|
||||
if (!file_exists($dirPath)) {
|
||||
mkdir($dirPath, 0777, true);
|
||||
}
|
||||
|
||||
$filePath = $dirPath . '/' . $filename;
|
||||
file_put_contents($filePath, $decodedData);
|
||||
|
||||
// Registra nel database
|
||||
$stmt = $pdo->prepare("
|
||||
INSERT INTO datadb_photos (idquotations, file_path, file_name, uploaded_at, uploaded_by)
|
||||
VALUES (:idquotations, :file_path, :file_name, NOW(), :uploaded_by)
|
||||
");
|
||||
$stmt->execute([
|
||||
':idquotations' => $idquotations,
|
||||
':file_path' => $filePath,
|
||||
':file_name' => $filename,
|
||||
':uploaded_by' => $iduserlogin
|
||||
]);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'file_path' => $filePath,
|
||||
'message' => 'Foto salvata con successo e registrata nel DB'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore: ' . $e->getMessage()]);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include('include/headscript.php');
|
||||
|
||||
$dbHandler = DBHandlerSelect::getInstance();
|
||||
$pdo = $dbHandler->getConnection();
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
$idquotations = $data['idquotations'] ?? null;
|
||||
$parts = $data['parts'] ?? [];
|
||||
|
||||
if (!$idquotations || empty($parts)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$part = $parts[0];
|
||||
$partId = $part['id'] ?? null;
|
||||
$partNumber = $part['part_number'] ?? null;
|
||||
$partDescription = $part['part_description'] ?? '';
|
||||
$mix = $part['mix'] ?? 'N';
|
||||
|
||||
if ($partDescription) {
|
||||
try {
|
||||
if ($partId) {
|
||||
// UPDATE se esiste già la parte
|
||||
$stmt = $pdo->prepare("UPDATE identification_parts
|
||||
SET part_number = :part_number,
|
||||
part_description = :part_description,
|
||||
mix = :mix,
|
||||
updated_at = NOW()
|
||||
WHERE id = :id");
|
||||
$stmt->execute([
|
||||
':id' => $partId,
|
||||
':part_number' => $partNumber,
|
||||
':part_description' => $partDescription,
|
||||
':mix' => $mix
|
||||
]);
|
||||
echo json_encode(['success' => true, 'part_id' => $partId, 'part_number' => $partNumber, 'message' => 'Parte aggiornata con successo']);
|
||||
} else {
|
||||
// INSERT se è nuova
|
||||
$stmt = $pdo->prepare("INSERT INTO identification_parts
|
||||
(idquotations, part_number, part_description, mix, created_at, updated_at)
|
||||
VALUES (:idquotations, :part_number, :part_description, :mix, NOW(), NOW())");
|
||||
$stmt->execute([
|
||||
':idquotations' => $idquotations,
|
||||
':part_number' => $partNumber,
|
||||
':part_description' => $partDescription,
|
||||
':mix' => $mix
|
||||
]);
|
||||
$newId = $pdo->lastInsertId();
|
||||
echo json_encode(['success' => true, 'part_id' => $newId, 'part_number' => $partNumber, 'message' => 'Parte salvata con successo']);
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nel salvataggio: ' . $e->getMessage()]);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Descrizione mancante']);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once 'include/headscript.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$template_id = $data['template_id'] ?? null;
|
||||
$mapping_id = $data['mapping_id'] ?? null;
|
||||
$value = $data['value'] ?? null;
|
||||
|
||||
if (!$template_id || !$mapping_id || !isset($value)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Invalid input']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
$stmt = $pdo->prepare("UPDATE template_mapping SET is_visible_import = ? WHERE id = ? AND template_id = ?");
|
||||
$result = $stmt->execute([$value, $mapping_id, $template_id]);
|
||||
|
||||
if ($result) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'message' => 'Failed to update is_visible_import']);
|
||||
}
|
||||
@@ -4,13 +4,23 @@ include('include/headscript.php');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_FILES['photo']) || !isset($_POST['iddatadb'])) {
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_FILES['photo']) || (!isset($_POST['iddatadb']) && !isset($_POST['idquotations']))) {
|
||||
echo json_encode(['success' => false, 'message' => 'Richiesta non valida']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$iddatadb = intval($_POST['iddatadb']);
|
||||
$photo = $_FILES['photo'];
|
||||
$iddatadb = isset($_POST['iddatadb']) ? intval($_POST['iddatadb']) : null;
|
||||
$idquotations = isset($_POST['idquotations']) ? intval($_POST['idquotations']) : null;
|
||||
|
||||
if ($iddatadb && $idquotations) {
|
||||
echo json_encode(['success' => false, 'message' => 'Non è possibile specificare sia iddatadb che idquotations']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$iddatadb && !$idquotations) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID TRF o ID quotations mancante']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica che l'utente loggato esista in auth_users
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
@@ -25,6 +35,28 @@ if (!$userExists) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Verifica l'esistenza dell'ID nella tabella corrispondente
|
||||
try {
|
||||
if ($iddatadb) {
|
||||
$stmt = $pdo->prepare("SELECT iddatadb FROM datadb WHERE iddatadb = ?");
|
||||
$stmt->execute([$iddatadb]);
|
||||
if (!$stmt->fetch()) {
|
||||
echo json_encode(['success' => false, 'message' => 'iddatadb non valido']);
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
$stmt = $pdo->prepare("SELECT id FROM quotations WHERE id = ?");
|
||||
$stmt->execute([$idquotations]);
|
||||
if (!$stmt->fetch()) {
|
||||
echo json_encode(['success' => false, 'message' => 'idquotations non valido']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore nella validazione: ' . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Usa un percorso assoluto per la cartella photostrf
|
||||
$uploadDir = realpath(__DIR__ . '/../photostrf') . '/';
|
||||
if (!is_dir($uploadDir)) {
|
||||
@@ -41,6 +73,7 @@ if (!is_writable($uploadDir)) {
|
||||
}
|
||||
|
||||
// Verifica che il file sia un'immagine (inclusi HEIC/HEIF)
|
||||
$photo = $_FILES['photo'];
|
||||
$allowedTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/heic', 'image/heif'];
|
||||
if (!in_array($photo['type'], $allowedTypes)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Il file deve essere un\'immagine (JPEG, PNG, GIF, HEIC)']);
|
||||
@@ -53,10 +86,11 @@ if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Rinomina il file: idriga-timestamp-nomeoriginale.estensione
|
||||
// Rinomina il file: id-timestamp-nomeoriginale.estensione
|
||||
$timestamp = date('YmdHis');
|
||||
$originalName = pathinfo($photo['name'], PATHINFO_FILENAME);
|
||||
$extension = strtolower(pathinfo($photo['name'], PATHINFO_EXTENSION));
|
||||
$id = $iddatadb ?: $idquotations;
|
||||
|
||||
// Se il file è HEIC/HEIF, convertilo in JPEG
|
||||
if (in_array($photo['type'], ['image/heic', 'image/heif'])) {
|
||||
@@ -74,11 +108,11 @@ if (in_array($photo['type'], ['image/heic', 'image/heif'])) {
|
||||
}
|
||||
|
||||
// Crea un nuovo nome per il file JPEG
|
||||
$newFileName = "{$iddatadb}-{$timestamp}-{$originalName}.jpg";
|
||||
$newFileName = "{$id}-{$timestamp}-{$originalName}.jpg";
|
||||
$destination = $uploadDir . $newFileName;
|
||||
|
||||
// Salva l'immagine come JPEG
|
||||
if (!imagejpeg($image, $destination, 90)) { // 90 è la qualità JPEG
|
||||
if (!imagejpeg($image, $destination, 90)) {
|
||||
imagedestroy($image);
|
||||
echo json_encode(['success' => false, 'message' => 'Errore durante la conversione del file HEIC in JPEG']);
|
||||
exit;
|
||||
@@ -88,7 +122,7 @@ if (in_array($photo['type'], ['image/heic', 'image/heif'])) {
|
||||
imagedestroy($image);
|
||||
} else {
|
||||
// Per i formati non HEIC, usa il nome e l'estensione originali
|
||||
$newFileName = "{$iddatadb}-{$timestamp}-{$originalName}.{$extension}";
|
||||
$newFileName = "{$id}-{$timestamp}-{$originalName}.{$extension}";
|
||||
$destination = $uploadDir . $newFileName;
|
||||
|
||||
// Salva il file
|
||||
@@ -105,7 +139,12 @@ error_log("Destination: $destination");
|
||||
error_log("Temp file: " . $photo['tmp_name']);
|
||||
|
||||
// Salva il riferimento nel database
|
||||
$stmt = $pdo->prepare("INSERT INTO datadb_photos (iddatadb, file_path, file_name, uploaded_by) VALUES (?, ?, ?, ?)");
|
||||
$stmt->execute([$iddatadb, $newFileName, $newFileName, $iduserlogin]);
|
||||
try {
|
||||
$stmt = $pdo->prepare("INSERT INTO datadb_photos (iddatadb, idquotations, file_path, file_name, uploaded_by) VALUES (?, ?, ?, ?, ?)");
|
||||
$stmt->execute([$iddatadb, $idquotations, $newFileName, $newFileName, $iduserlogin]);
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(['success' => false, 'message' => 'Errore durante il salvataggio nel database: ' . $e->getMessage()]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Foto caricata con successo']);
|
||||
|
||||
@@ -5,24 +5,41 @@ include('include/headscript.php');
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Verifica che l'iddatadb sia stato passato
|
||||
if (!isset($_GET['iddatadb']) || empty($_GET['iddatadb'])) {
|
||||
die('ID riga non fornito');
|
||||
// Verifica che almeno uno degli ID sia passato
|
||||
$iddatadb = isset($_GET['iddatadb']) && !empty($_GET['iddatadb']) ? intval($_GET['iddatadb']) : null;
|
||||
$idquotations = isset($_GET['idquotations']) && !empty($_GET['idquotations']) ? intval($_GET['idquotations']) : null;
|
||||
|
||||
if (!$iddatadb && !$idquotations) {
|
||||
die('ID riga o ID quotations non fornito');
|
||||
}
|
||||
|
||||
$iddatadb = intval($_GET['iddatadb']);
|
||||
if ($iddatadb && $idquotations) {
|
||||
die('Non è possibile specificare sia iddatadb che idquotations');
|
||||
}
|
||||
|
||||
// Recupera i dettagli della riga (idriga e sample_code)
|
||||
$stmt = $pdo->prepare("SELECT iddatadb, sample_code FROM datadb WHERE iddatadb = ?");
|
||||
$stmt->execute([$iddatadb]);
|
||||
// Verifica che l'utente loggato esista
|
||||
$stmt = $pdo->prepare("SELECT id FROM auth_users WHERE id = ?");
|
||||
$stmt->execute([$iduserlogin]);
|
||||
if (!$stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
die('Utente non valido');
|
||||
}
|
||||
|
||||
// Determina quale ID usare e verifica l'esistenza
|
||||
$paramName = $iddatadb ? 'iddatadb' : 'idquotations';
|
||||
$paramValue = $iddatadb ?: $idquotations;
|
||||
$table = $iddatadb ? 'datadb' : 'quotations';
|
||||
$field = $iddatadb ? 'sample_code' : 'quotation_code';
|
||||
|
||||
$stmt = $pdo->prepare("SELECT {$paramName}, {$field} FROM {$table} WHERE {$paramName} = ?");
|
||||
$stmt->execute([$paramValue]);
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$row) {
|
||||
die('Riga non trovata');
|
||||
}
|
||||
|
||||
$idriga = $row['iddatadb'];
|
||||
$sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||
$id = $row[$paramName];
|
||||
$code = $row[$field] ?? 'Non disponibile';
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -32,17 +49,23 @@ $sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Carica Foto da Mobile</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
background: #f4f4f4;
|
||||
}
|
||||
|
||||
.upload-area {
|
||||
border: 2px dashed #ccc;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
margin: 20px auto;
|
||||
max-width: 500px;
|
||||
background: white;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.upload-area.highlight {
|
||||
@@ -56,57 +79,121 @@ $sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 10px;
|
||||
max-width: 500px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.photo-item img {
|
||||
max-width: 100px;
|
||||
max-height: 100px;
|
||||
margin-right: 10px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.loader {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.loader i {
|
||||
font-size: 40px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: red;
|
||||
margin: 10px 0;
|
||||
display: none;
|
||||
}
|
||||
|
||||
button.delete-photo-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: #dc3545;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Carica Foto per ID Riga: <?= htmlspecialchars($idriga) ?></h2>
|
||||
<p><strong>Sample Code:</strong> <?= htmlspecialchars($sampleCode) ?></p>
|
||||
|
||||
<h2>Carica Foto per ID: <?= htmlspecialchars($id) ?></h2>
|
||||
<p><strong>Codice:</strong> <?= htmlspecialchars($code) ?></p>
|
||||
<div class="loader" id="loader">
|
||||
<div>
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<p>Caricamento in corso...</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="error-message" id="errorMessage"></div>
|
||||
<div class="upload-area" id="uploadArea">
|
||||
<p>Scatta una foto o seleziona un'immagine</p>
|
||||
<input type="file" id="photoInput" accept="image/*" capture="camera">
|
||||
</div>
|
||||
|
||||
<div id="photosList">
|
||||
<!-- Le foto verranno caricate dinamicamente -->
|
||||
<p>Scatta una foto o seleziona immagini</p>
|
||||
<input type="file" id="photoInput" accept="image/*" capture="camera" multiple style="display: none;">
|
||||
</div>
|
||||
<div id="photosList"></div>
|
||||
|
||||
<script>
|
||||
const uploadArea = document.getElementById('uploadArea');
|
||||
const photoInput = document.getElementById('photoInput');
|
||||
const photosList = document.getElementById('photosList');
|
||||
const loader = document.getElementById('loader');
|
||||
const errorMessage = document.getElementById('errorMessage');
|
||||
const iddatadb = '<?= $iddatadb ?>';
|
||||
const idquotations = '<?= $idquotations ?>';
|
||||
const endpoint = idquotations ? 'load_photo_quotation.php' : 'load_photo.php';
|
||||
const dataParam = idquotations ? {
|
||||
idquotations: idquotations
|
||||
} : {
|
||||
iddatadb: iddatadb
|
||||
};
|
||||
|
||||
// Carica le foto esistenti all'avvio
|
||||
loadPhotos();
|
||||
|
||||
// Gestione del click sull'area di upload
|
||||
uploadArea.addEventListener('click', () => {
|
||||
photoInput.click();
|
||||
// Gestione drag-and-drop
|
||||
uploadArea.addEventListener('dragover', (e) => {
|
||||
e.preventDefault();
|
||||
uploadArea.classList.add('highlight');
|
||||
});
|
||||
uploadArea.addEventListener('dragleave', () => {
|
||||
uploadArea.classList.remove('highlight');
|
||||
});
|
||||
uploadArea.addEventListener('drop', (e) => {
|
||||
e.preventDefault();
|
||||
uploadArea.classList.remove('highlight');
|
||||
handleFiles(e.dataTransfer.files);
|
||||
});
|
||||
|
||||
// Gestione del caricamento delle foto
|
||||
photoInput.addEventListener('change', () => {
|
||||
handleFiles(photoInput.files);
|
||||
});
|
||||
// Gestione click sull'area di upload
|
||||
uploadArea.addEventListener('click', () => photoInput.click());
|
||||
|
||||
// Gestione caricamento foto
|
||||
photoInput.addEventListener('change', () => handleFiles(photoInput.files));
|
||||
|
||||
async function handleFiles(files) {
|
||||
loader.style.display = 'flex';
|
||||
errorMessage.style.display = 'none';
|
||||
for (const file of files) {
|
||||
if (!file.type.startsWith('image/')) {
|
||||
alert('Per favore, carica solo immagini!');
|
||||
showError('Per favore, carica solo immagini!');
|
||||
continue;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('photo', file);
|
||||
formData.append('iddatadb', '<?= $iddatadb ?>');
|
||||
if (iddatadb) formData.append('iddatadb', iddatadb);
|
||||
if (idquotations) formData.append('idquotations', idquotations);
|
||||
|
||||
try {
|
||||
const response = await fetch('upload_photo.php', {
|
||||
@@ -114,31 +201,85 @@ $sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||
body: formData
|
||||
});
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
loadPhotos(); // Ricarica le foto
|
||||
} else {
|
||||
alert('Errore durante il caricamento: ' + result.message);
|
||||
if (!result.success) {
|
||||
showError('Errore durante il caricamento: ' + result.message);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Errore durante il caricamento: ' + error.message);
|
||||
showError('Errore di rete: ' + error.message);
|
||||
}
|
||||
}
|
||||
loadPhotos();
|
||||
loader.style.display = 'none';
|
||||
}
|
||||
|
||||
// Funzione per caricare le foto esistenti
|
||||
async function loadPhotos() {
|
||||
loader.style.display = 'flex';
|
||||
errorMessage.style.display = 'none';
|
||||
try {
|
||||
const response = await fetch(`photos_popup.php?iddatadb=<?= $iddatadb ?>`);
|
||||
const html = await response.text();
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(html, 'text/html');
|
||||
const photosListContent = doc.querySelector('#photosList').innerHTML;
|
||||
photosList.innerHTML = photosListContent;
|
||||
const response = await fetch(`${endpoint}?${new URLSearchParams(dataParam)}`);
|
||||
const result = await response.json();
|
||||
photosList.innerHTML = '';
|
||||
if (result.success && result.photos && result.photos.length > 0) {
|
||||
for (const photo of result.photos) {
|
||||
const photoName = photo.split('/').pop();
|
||||
const photoItem = document.createElement('div');
|
||||
photoItem.className = 'photo-item';
|
||||
photoItem.innerHTML = `
|
||||
<img src="${photo}" alt="${photoName}">
|
||||
<div style="flex: 1; text-align: left;">
|
||||
<strong>Nome:</strong> ${photoName}<br>
|
||||
<strong>Caricata il:</strong> Non disponibile
|
||||
</div>
|
||||
<button class="delete-photo-btn" data-photo-path="${photo}">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>`;
|
||||
photosList.appendChild(photoItem);
|
||||
}
|
||||
} else {
|
||||
photosList.innerHTML = '<p>Nessuna foto presente.</p>';
|
||||
}
|
||||
} catch (error) {
|
||||
photosList.innerHTML = `<p>Errore durante il caricamento delle foto: ${error.message}</p>`;
|
||||
showError('Errore durante il caricamento delle foto: ' + error.message);
|
||||
}
|
||||
loader.style.display = 'none';
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
errorMessage.textContent = message;
|
||||
errorMessage.style.display = 'block';
|
||||
setTimeout(() => errorMessage.style.display = 'none', 5000);
|
||||
}
|
||||
|
||||
// Gestione eliminazione foto
|
||||
photosList.addEventListener('click', async (e) => {
|
||||
if (e.target.closest('.delete-photo-btn')) {
|
||||
const button = e.target.closest('.delete-photo-btn');
|
||||
const photoPath = button.dataset.photoPath;
|
||||
if (confirm('Sei sicuro di voler eliminare questa foto?')) {
|
||||
loader.style.display = 'flex';
|
||||
try {
|
||||
const response = await fetch('delete_photo.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
file_path: photoPath
|
||||
})
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
loadPhotos();
|
||||
} else {
|
||||
showError('Errore durante l\'eliminazione: ' + result.message);
|
||||
}
|
||||
} catch (error) {
|
||||
showError('Errore durante l\'eliminazione: ' + error.message);
|
||||
}
|
||||
loader.style.display = 'none';
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user