added photo functionality
This commit is contained in:
parent
8cad59e3d6
commit
f8388bc81b
@ -30,6 +30,7 @@
|
|||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"akaunting/laravel-setting": "^1.2.9",
|
"akaunting/laravel-setting": "^1.2.9",
|
||||||
"anhskohbo/no-captcha": "3.*",
|
"anhskohbo/no-captcha": "3.*",
|
||||||
|
"endroid/qr-code": "^6.0",
|
||||||
"guzzlehttp/guzzle": "^7.2",
|
"guzzlehttp/guzzle": "^7.2",
|
||||||
"intervention/image": "^2.3",
|
"intervention/image": "^2.3",
|
||||||
"jenssegers/agent": "^2.5",
|
"jenssegers/agent": "^2.5",
|
||||||
|
|||||||
74
composer.lock
generated
74
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "a7749f3b43e37d8fb607bcccd227f5ee",
|
"content-hash": "ef3e05e7260284f5b7c7b4b6f93b252b",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "akaunting/laravel-setting",
|
"name": "akaunting/laravel-setting",
|
||||||
@ -820,6 +820,78 @@
|
|||||||
],
|
],
|
||||||
"time": "2023-10-06T06:47:41+00:00"
|
"time": "2023-10-06T06:47:41+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "endroid/qr-code",
|
||||||
|
"version": "6.0.6",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/endroid/qr-code.git",
|
||||||
|
"reference": "11e6a94458dab8dd18736c11892130ec788b5028"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/endroid/qr-code/zipball/11e6a94458dab8dd18736c11892130ec788b5028",
|
||||||
|
"reference": "11e6a94458dab8dd18736c11892130ec788b5028",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"bacon/bacon-qr-code": "^3.0",
|
||||||
|
"php": "^8.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"endroid/quality": "dev-main",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"khanamiryan/qrcode-detector-decoder": "^2.0.2",
|
||||||
|
"setasign/fpdf": "^1.8.2"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-gd": "Enables you to write PNG images",
|
||||||
|
"khanamiryan/qrcode-detector-decoder": "Enables you to use the image validator",
|
||||||
|
"roave/security-advisories": "Makes sure package versions with known security issues are not installed",
|
||||||
|
"setasign/fpdf": "Enables you to use the PDF writer"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-main": "6.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Endroid\\QrCode\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Jeroen van den Enden",
|
||||||
|
"email": "info@endroid.nl"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Endroid QR Code",
|
||||||
|
"homepage": "https://github.com/endroid/qr-code",
|
||||||
|
"keywords": [
|
||||||
|
"code",
|
||||||
|
"endroid",
|
||||||
|
"php",
|
||||||
|
"qr",
|
||||||
|
"qrcode"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/endroid/qr-code/issues",
|
||||||
|
"source": "https://github.com/endroid/qr-code/tree/6.0.6"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/endroid",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2025-03-14T23:29:08+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "firebase/php-jwt",
|
"name": "firebase/php-jwt",
|
||||||
"version": "v6.10.1",
|
"version": "v6.10.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
// general terms
|
// general terms
|
||||||
$titlewebsite = "TRF Certest";
|
$titlewebsite = "TRF Smart";
|
||||||
|
|
||||||
$accountsettings = "Account Settings";
|
$accountsettings = "Account Settings";
|
||||||
$userprofile = "User Profile";
|
$userprofile = "User Profile";
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
BIN
public/photostrf/qrcodes/qrcode_228.png
Normal file
BIN
public/photostrf/qrcodes/qrcode_228.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 510 B |
98
public/userarea/debug.log
Normal file
98
public/userarea/debug.log
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"}}
|
||||||
|
HTTP Code: 400
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"},"success":false,"http_code":400}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings?tracking_numbers=750000810057432004040056&courier_code=tnt-it
|
||||||
|
Request Data: []
|
||||||
|
Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[]}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Get Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[],"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"}}
|
||||||
|
HTTP Code: 400
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"},"success":false,"http_code":400}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/get?tracking_numbers=750000810057432004040056&courier_code=tnt-it
|
||||||
|
Request Data: []
|
||||||
|
Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[]}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Get Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[],"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"}}
|
||||||
|
HTTP Code: 400
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":4101,"message":"Tracking No. already exists."},"data":{"id":"9e85e85acd18a1c92d9fa1f6fede8a23","tracking_number":"750000810057432004040056","courier_code":"tnt-it"},"success":false,"http_code":400}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/get?tracking_numbers=750000810057432004040056
|
||||||
|
Request Data: []
|
||||||
|
Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[]}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Get Response: {"meta":{"code":200,"type":"Success","message":"The request was successful."},"data":[],"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e85f77564ba2d1b2d35c7b28c72e62b","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-26T09:43:15+00:00","update_at":"2025-03-26T09:01:02+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}}}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e85f77564ba2d1b2d35c7b28c72e62b","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-26T09:43:15+00:00","update_at":"2025-03-26T09:01:02+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}},"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e8601d0116ffa9f4abe6fa609f27214","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-26T10:12:12+00:00","update_at":"2025-03-26T09:43:15+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}}}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e8601d0116ffa9f4abe6fa609f27214","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-26T10:12:12+00:00","update_at":"2025-03-26T09:43:15+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}},"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "75000",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"75000","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e88676cc0b94ee0270add7c597d0cb0","tracking_number":"75000","courier_code":"tnt-it","order_number":"75000","order_date":null,"created_at":"2025-03-27T14:47:59+00:00","update_at":null,"delivery_status":"pending","archived":"tracking","updating":true,"source":"API","destination_country":null,"destination_state":null,"destination_city":null,"origin_country":null,"origin_state":null,"origin_city":null,"tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":null,"service_code":null,"weight":null,"weight_kg":null,"product_type":null,"pieces":null,"dimension":null,"previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"pending002","status_info":null,"latest_event":null,"latest_checkpoint_time":null,"transit_time":0,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}}}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e88676cc0b94ee0270add7c597d0cb0","tracking_number":"75000","courier_code":"tnt-it","order_number":"75000","order_date":null,"created_at":"2025-03-27T14:47:59+00:00","update_at":null,"delivery_status":"pending","archived":"tracking","updating":true,"source":"API","destination_country":null,"destination_state":null,"destination_city":null,"origin_country":null,"origin_state":null,"origin_city":null,"tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":null,"service_code":null,"weight":null,"weight_kg":null,"product_type":null,"pieces":null,"dimension":null,"previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"pending002","status_info":null,"latest_event":null,"latest_checkpoint_time":null,"transit_time":0,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}},"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "750000810057432004040056",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"750000810057432004040056","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e8867d062b0ddfac8655e3d81b289af","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-27T14:49:04+00:00","update_at":"2025-03-26T10:12:12+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}}}
|
||||||
|
HTTP Code: 200
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":200,"message":"Request response is successful"},"data":{"id":"9e8867d062b0ddfac8655e3d81b289af","tracking_number":"750000810057432004040056","courier_code":"tnt-it","order_number":"750000810057432004040056","order_date":null,"created_at":"2025-03-27T14:49:04+00:00","update_at":"2025-03-26T10:12:12+00:00","delivery_status":"delivered","archived":"tracking","updating":false,"source":"API","destination_country":"IT","destination_state":"MB","destination_city":"MEDA","origin_country":null,"origin_state":"BS","origin_city":"BRESCIA","tracking_postal_code":null,"tracking_ship_date":null,"tracking_destination_country":null,"tracking_origin_country":null,"tracking_key":null,"tracking_courier_account":null,"customer_name":null,"customer_email":null,"customer_sms":null,"recipient_postcode":null,"order_id":null,"title":null,"logistics_channel":null,"note":null,"label":null,"signed_by":"SIRONI","service_code":"Express","weight":"0,020","weight_kg":null,"product_type":null,"pieces":"1","dimension":"0,001","previously":null,"destination_track_number":null,"exchange_number":null,"scheduled_delivery_date":null,"scheduled_address":null,"substatus":"delivered003","status_info":null,"latest_event":"Spedizione consegnata,COMO,2025-03-25 11:12:00","latest_checkpoint_time":"2025-03-25T11:12:00","transit_time":1,"origin_info":{"courier_code":"tnt-it","courier_phone":"+39 199 803 868","weblink":"http:\/\/www.tnt.it\/","tracking_link":"https:\/\/www.tnt.it\/tracking\/Tracking.do","reference_number":"MY01818480","milestone_date":{"inforeceived_date":null,"pickup_date":"2025-03-24T17:35:00","outfordelivery_date":"2025-03-25T09:31:00","delivery_date":"2025-03-25T11:12:00","returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[{"checkpoint_date":"2025-03-25T11:12:00","checkpoint_delivery_status":"delivered","checkpoint_delivery_substatus":"delivered003","tracking_detail":"Spedizione consegnata","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T09:31:00","checkpoint_delivery_status":"pickup","checkpoint_delivery_substatus":"pickup001","tracking_detail":"La spedizione e' in consegna in data odierna","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-25T01:11:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' in transito","location":"COMO","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null},{"checkpoint_date":"2025-03-24T17:35:00","checkpoint_delivery_status":"transit","checkpoint_delivery_substatus":"transit001","tracking_detail":"La spedizione e' regolarmente partita","location":"BRESCIA","country_iso2":null,"state":null,"city":null,"zip":null,"raw_status":null}]},"destination_info":{"courier_code":null,"courier_phone":null,"weblink":null,"tracking_link":null,"reference_number":null,"milestone_date":{"inforeceived_date":null,"pickup_date":null,"outfordelivery_date":null,"delivery_date":null,"returning_date":null,"returned_date":null},"pickup_date":null,"departed_airport_date":null,"arrived_abroad_date":null,"customs_received_date":null,"trackinfo":[]}},"success":true,"http_code":200}
|
||||||
|
Encoded JSON Data: {
|
||||||
|
"tracking_number": "123",
|
||||||
|
"courier_code": "tnt-it"
|
||||||
|
}
|
||||||
|
Request URL: https://api.trackingmore.com/v4/trackings/create
|
||||||
|
Request Data: {"tracking_number":"123","courier_code":"tnt-it"}
|
||||||
|
Response: {"meta":{"code":4110,"message":"The value of tracking_number is invalid."},"data":null}
|
||||||
|
HTTP Code: 400
|
||||||
|
Error:
|
||||||
|
Create Response: {"meta":{"code":4110,"message":"The value of tracking_number is invalid."},"data":null,"success":false,"http_code":400}
|
||||||
37
public/userarea/delete_photo.php
Normal file
37
public/userarea/delete_photo.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
// delete_photo.php
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['photo_id'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Richiesta non valida']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$photoId = intval($_POST['photo_id']);
|
||||||
|
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
// Recupera il percorso del file
|
||||||
|
$stmt = $pdo->prepare("SELECT file_path FROM datadb_photos WHERE id = ?");
|
||||||
|
$stmt->execute([$photoId]);
|
||||||
|
$photo = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$photo) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Foto non trovata']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Elimina il file dal server
|
||||||
|
$filePath = '../photostrf/' . $photo['file_path'];
|
||||||
|
if (file_exists($filePath)) {
|
||||||
|
unlink($filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Elimina il record dal database
|
||||||
|
$stmt = $pdo->prepare("DELETE FROM datadb_photos WHERE id = ?");
|
||||||
|
$stmt->execute([$photoId]);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Foto eliminata con successo']);
|
||||||
150
public/userarea/fetch_tracking_info.php
Normal file
150
public/userarea/fetch_tracking_info.php
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
<?php
|
||||||
|
// Abilita il debug degli errori (solo per sviluppo)
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
// Assicurati che non ci sia output prima del JSON
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// Imposta l'header per JSON
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// Configura la tua chiave API di TrackingMore
|
||||||
|
$apiKey = 'u4ssgynn-xuyy-9act-ca29-2glsv2qlzh0w'; // La tua chiave API reale
|
||||||
|
|
||||||
|
// Funzione per inviare una risposta JSON e terminare l'esecuzione
|
||||||
|
function sendResponse($data)
|
||||||
|
{
|
||||||
|
ob_end_clean();
|
||||||
|
echo json_encode($data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica che il numero di tracking e il corriere siano stati inviati
|
||||||
|
if (!isset($_POST['tracking_number']) || empty($_POST['tracking_number']) || !isset($_POST['courier_code']) || empty($_POST['courier_code'])) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Numero di tracking o corriere non fornito']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trackingNumber = $_POST['tracking_number'];
|
||||||
|
$courierCode = $_POST['courier_code'];
|
||||||
|
|
||||||
|
// Lista dei corrieri validi per validazione
|
||||||
|
$validCarriers = ['tnt-it', 'dhl', 'gls', 'sda', 'ups'];
|
||||||
|
if (!in_array($courierCode, $validCarriers)) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Corriere non valido']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Imposta il nome del corriere in base al codice
|
||||||
|
$carrierNames = [
|
||||||
|
'tnt-it' => 'TNT Italy',
|
||||||
|
'dhl' => 'DHL',
|
||||||
|
'gls' => 'GLS',
|
||||||
|
'sda' => 'SDA',
|
||||||
|
'ups' => 'UPS'
|
||||||
|
];
|
||||||
|
$courierName = $carrierNames[$courierCode];
|
||||||
|
|
||||||
|
// Funzione per fare una richiesta cURL a TrackingMore
|
||||||
|
function makeRequest($url, $data, $apiKey, $method = 'POST')
|
||||||
|
{
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
|
'Tracking-Api-Key: ' . $apiKey,
|
||||||
|
'Content-Type: application/json'
|
||||||
|
]);
|
||||||
|
if ($method === 'POST') {
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
$jsonData = json_encode($data, JSON_PRETTY_PRINT);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
|
||||||
|
file_put_contents('debug.log', "Encoded JSON Data: $jsonData\n", FILE_APPEND);
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$error = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
file_put_contents('debug.log', "Request URL: $url\nRequest Data: " . json_encode($data) . "\nResponse: $response\nHTTP Code: $httpCode\nError: $error\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if ($response === false) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Errore nella richiesta API: ' . $error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedResponse = json_decode($response, true);
|
||||||
|
if ($decodedResponse === null) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Risposta API non valida (non è JSON)'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedResponse['success'] = isset($decodedResponse['meta']['code']) && ($decodedResponse['meta']['code'] === 200 || $decodedResponse['meta']['code'] === 201);
|
||||||
|
$decodedResponse['http_code'] = $httpCode;
|
||||||
|
return $decodedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 1: Prova a creare il tracking
|
||||||
|
$createUrl = 'https://api.trackingmore.com/v4/trackings/create';
|
||||||
|
$createData = [
|
||||||
|
'tracking_number' => $trackingNumber,
|
||||||
|
'courier_code' => $courierCode
|
||||||
|
];
|
||||||
|
$createResponse = makeRequest($createUrl, $createData, $apiKey);
|
||||||
|
file_put_contents('debug.log', "Create Response: " . json_encode($createResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
$trackingInfo = null;
|
||||||
|
if ($createResponse['success']) {
|
||||||
|
// Creazione riuscita, usa i dati restituiti
|
||||||
|
$trackingInfo = $createResponse['data'];
|
||||||
|
} else {
|
||||||
|
// Controlla se l'errore è "Tracking No. already exists" (4101)
|
||||||
|
if (isset($createResponse['meta']['code']) && $createResponse['meta']['code'] === 4101) {
|
||||||
|
// Il tracking esiste già, usa /trackings (GET) con tracking_number e courier_code
|
||||||
|
$getUrl = 'https://api.trackingmore.com/v4/get?tracking_numbers=' . urlencode($trackingNumber);
|
||||||
|
$getResponse = makeRequest($getUrl, [], $apiKey, 'GET');
|
||||||
|
file_put_contents('debug.log', "Get Response: " . json_encode($getResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if ($getResponse['success'] && !empty($getResponse['data']['items']) && !empty($getResponse['data']['items'][0])) {
|
||||||
|
$trackingInfo = $getResponse['data']['items'][0];
|
||||||
|
} else {
|
||||||
|
$errorMessage = isset($getResponse['meta']['message']) ? $getResponse['meta']['message'] : 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nel recupero del tracking esistente: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Altro errore nella creazione
|
||||||
|
$errorMessage = isset($createResponse['meta']['message']) ? $createResponse['meta']['message'] : 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nella creazione del tracking: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$trackingInfo) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Nessuna informazione di tracking trovata']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estrai la data di consegna e il firmatario
|
||||||
|
$deliveryDate = 'Non disponibile';
|
||||||
|
$signedBy = 'Non disponibile';
|
||||||
|
if (isset($trackingInfo['origin_info']['trackinfo']) && is_array($trackingInfo['origin_info']['trackinfo'])) {
|
||||||
|
foreach ($trackingInfo['origin_info']['trackinfo'] as $checkpoint) {
|
||||||
|
if (isset($checkpoint['checkpoint_delivery_status']) && $checkpoint['checkpoint_delivery_status'] === 'delivered') {
|
||||||
|
$deliveryDate = $checkpoint['checkpoint_date'] ?? 'Non disponibile';
|
||||||
|
$signedBy = $trackingInfo['signed_by'] ?? 'Non disponibile';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restituisci i dati al frontend
|
||||||
|
sendResponse([
|
||||||
|
'success' => true,
|
||||||
|
'deliveryDate' => $deliveryDate,
|
||||||
|
'signedBy' => $signedBy,
|
||||||
|
'carrierName' => $courierName
|
||||||
|
]);
|
||||||
166
public/userarea/fetch_tracking_info17track.php
Normal file
166
public/userarea/fetch_tracking_info17track.php
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
// Abilita il debug degli errori (solo per sviluppo)
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
// Assicurati che non ci sia output prima del JSON
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// Imposta l'header per JSON
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// Configura la tua chiave API di 17Track
|
||||||
|
$apiKey = '489F6B6DADDE09A5B6CB1C42B5363A3F'; // Sostituisci con la tua chiave API reale
|
||||||
|
|
||||||
|
// Funzione per inviare una risposta JSON e terminare l'esecuzione
|
||||||
|
function sendResponse($data)
|
||||||
|
{
|
||||||
|
ob_end_clean();
|
||||||
|
echo json_encode($data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica che il numero di tracking sia stato inviato
|
||||||
|
if (!isset($_POST['tracking_number']) || empty($_POST['tracking_number'])) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Numero di tracking non fornito']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trackingNumber = $_POST['tracking_number'];
|
||||||
|
|
||||||
|
// Funzione per fare una richiesta cURL a 17Track
|
||||||
|
function makeRequest($url, $data, $apiKey, $method = 'POST')
|
||||||
|
{
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
|
'17token: ' . $apiKey,
|
||||||
|
'Content-Type: application/json'
|
||||||
|
]);
|
||||||
|
if ($method === 'POST') {
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$error = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
file_put_contents('debug.log', "Request URL: $url\nRequest Data: " . json_encode($data) . "\nResponse: $response\nHTTP Code: $httpCode\nError: $error\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if ($response === false || $httpCode !== 200) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Errore nella richiesta API: HTTP ' . $httpCode . ' - ' . $error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedResponse = json_decode($response, true);
|
||||||
|
if ($decodedResponse === null) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Risposta API non valida (non è JSON)'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $decodedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 1: Prova con auto-detection
|
||||||
|
$trackUrl = 'https://api.17track.net/track/v2/register';
|
||||||
|
$trackData = [
|
||||||
|
[
|
||||||
|
'number' => $trackingNumber,
|
||||||
|
'carrier' => null,
|
||||||
|
'auto_detection' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$registerResponse = makeRequest($trackUrl, $trackData, $apiKey);
|
||||||
|
|
||||||
|
file_put_contents('debug.log', "Register Response (Auto-detect): " . json_encode($registerResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if (!isset($registerResponse['data']['accepted']) || empty($registerResponse['data']['accepted'])) {
|
||||||
|
$errorMessage = $registerResponse['data']['rejected'][0]['error']['message'] ?? 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nella registrazione del tracking: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Recupera i dettagli con riprova
|
||||||
|
$getUrl = 'https://api.17track.net/track/v2/gettrackinfo';
|
||||||
|
$getData = [['number' => $trackingNumber]];
|
||||||
|
$maxAttempts = 3;
|
||||||
|
$delaySeconds = 5;
|
||||||
|
|
||||||
|
for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
|
||||||
|
$trackResponse = makeRequest($getUrl, $getData, $apiKey);
|
||||||
|
file_put_contents('debug.log', "Track Response (Attempt $attempt): " . json_encode($trackResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if (isset($trackResponse['data']['accepted']) && !empty($trackResponse['data']['accepted'])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($attempt < $maxAttempts) {
|
||||||
|
sleep($delaySeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Se auto-detection ha successo, procedi
|
||||||
|
if (isset($trackResponse['data']['accepted']) && !empty($trackResponse['data']['accepted'])) {
|
||||||
|
$trackingInfo = $trackResponse['data']['accepted'][0]['track'] ?? null;
|
||||||
|
if (!$trackingInfo) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Nessuna informazione di tracking trovata']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$deliveryDate = 'Non disponibile';
|
||||||
|
$signedBy = 'Non disponibile';
|
||||||
|
$carrierName = $trackingInfo['carrier']['name'] ?? 'Sconosciuto';
|
||||||
|
|
||||||
|
if (isset($trackingInfo['z0']['e']) && $trackingInfo['z0']['e'] == 40) {
|
||||||
|
$deliveryDate = $trackingInfo['z0']['z'] ?? 'Non disponibile';
|
||||||
|
$signedBy = $trackingInfo['z0']['d'] ?? 'Non disponibile';
|
||||||
|
}
|
||||||
|
|
||||||
|
sendResponse([
|
||||||
|
'success' => true,
|
||||||
|
'deliveryDate' => $deliveryDate,
|
||||||
|
'signedBy' => $signedBy,
|
||||||
|
'carrierName' => $carrierName
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Se auto-detection fallisce, prova una lista di corrieri comuni
|
||||||
|
$commonCarriers = [
|
||||||
|
['code' => 100003, 'name' => 'TNT'], // TNT
|
||||||
|
['code' => 100001, 'name' => 'DHL'], // DHL Express
|
||||||
|
['code' => 100065, 'name' => 'DHL eCommerce'], // DHL eCommerce
|
||||||
|
['code' => 100002, 'name' => 'UPS'] // UPS
|
||||||
|
];
|
||||||
|
|
||||||
|
$possibleCarriers = [];
|
||||||
|
foreach ($commonCarriers as $carrier) {
|
||||||
|
$trackData = [
|
||||||
|
[
|
||||||
|
'number' => $trackingNumber,
|
||||||
|
'carrier' => $carrier['code'],
|
||||||
|
'auto_detection' => false
|
||||||
|
]
|
||||||
|
];
|
||||||
|
$registerResponse = makeRequest($trackUrl, $trackData, $apiKey);
|
||||||
|
|
||||||
|
if (isset($registerResponse['data']['accepted']) && !empty($registerResponse['data']['accepted'])) {
|
||||||
|
$possibleCarriers[] = $carrier['name'];
|
||||||
|
}
|
||||||
|
sleep(1); // Piccolo ritardo per evitare limiti di rate
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($possibleCarriers)) {
|
||||||
|
sendResponse([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Auto-detection fallita. Seleziona un corriere tra quelli possibili.',
|
||||||
|
'possibleCarriers' => $possibleCarriers
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Nessun corriere identificato per questo numero di tracking']);
|
||||||
|
}
|
||||||
166
public/userarea/fetch_tracking_infotracking.php
Normal file
166
public/userarea/fetch_tracking_infotracking.php
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
<?php
|
||||||
|
// Abilita il debug degli errori (solo per sviluppo)
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
ini_set('display_startup_errors', 1);
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
|
// Assicurati che non ci sia output prima del JSON
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
// Imposta l'header per JSON
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
// Configura la tua chiave API di TrackingMore
|
||||||
|
$apiKey = 'u4ssgynn-xuyy-9act-ca29-2glsv2qlzh0w'; // La tua chiave API reale
|
||||||
|
|
||||||
|
// Funzione per inviare una risposta JSON e terminare l'esecuzione
|
||||||
|
function sendResponse($data)
|
||||||
|
{
|
||||||
|
ob_end_clean();
|
||||||
|
echo json_encode($data);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica che il numero di tracking sia stato inviato
|
||||||
|
if (!isset($_POST['tracking_number']) || empty($_POST['tracking_number'])) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Numero di tracking non fornito']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trackingNumber = $_POST['tracking_number'];
|
||||||
|
|
||||||
|
// Funzione per fare una richiesta cURL a TrackingMore
|
||||||
|
function makeRequest($url, $data, $apiKey, $method = 'POST')
|
||||||
|
{
|
||||||
|
$ch = curl_init($url);
|
||||||
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||||
|
'Tracking-Api-Key: ' . $apiKey,
|
||||||
|
'Content-Type: application/json'
|
||||||
|
]);
|
||||||
|
if ($method === 'POST') {
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
|
||||||
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||||
|
$response = curl_exec($ch);
|
||||||
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
|
$error = curl_error($ch);
|
||||||
|
curl_close($ch);
|
||||||
|
|
||||||
|
file_put_contents('debug.log', "Request URL: $url\nRequest Data: " . json_encode($data) . "\nResponse: $response\nHTTP Code: $httpCode\nError: $error\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if ($response === false || ($httpCode !== 200 && $httpCode !== 201)) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Errore nella richiesta API: HTTP ' . $httpCode . ' - ' . $error
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedResponse = json_decode($response, true);
|
||||||
|
if ($decodedResponse === null) {
|
||||||
|
return [
|
||||||
|
'success' => false,
|
||||||
|
'code' => $httpCode,
|
||||||
|
'message' => 'Risposta API non valida (non è JSON)'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$decodedResponse['success'] = isset($decodedResponse['meta']['code']) && ($decodedResponse['meta']['code'] === 200 || $decodedResponse['meta']['code'] === 201);
|
||||||
|
return $decodedResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 1: Identifica il corriere
|
||||||
|
$detectUrl = 'https://api.trackingmore.com/v4/couriers/detect';
|
||||||
|
$detectData = ['tracking_number' => $trackingNumber];
|
||||||
|
$detectResponse = makeRequest($detectUrl, $detectData, $apiKey);
|
||||||
|
file_put_contents('debug.log', "Detect Response: " . json_encode($detectResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if (!$detectResponse['success']) {
|
||||||
|
$errorMessage = isset($detectResponse['meta']['message']) ? $detectResponse['meta']['message'] : 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nella rilevazione del corriere: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$couriers = $detectResponse['data'] ?? [];
|
||||||
|
if (empty($couriers)) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Corriere non identificato per il numero di tracking']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prendi il primo corriere per ora
|
||||||
|
$courierCode = $couriers[0]['courier_code'] ?? null;
|
||||||
|
$courierName = $couriers[0]['courier_name'] ?? 'Sconosciuto';
|
||||||
|
if (!$courierCode) {
|
||||||
|
sendResponse(['success' => false, 'message' => 'Corriere non identificato']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 2: Crea un tracking
|
||||||
|
$createUrl = 'https://api.trackingmore.com/v4/trackings/create';
|
||||||
|
$createData = [
|
||||||
|
'tracking_number' => $trackingNumber,
|
||||||
|
'courier_code' => $courierCode
|
||||||
|
];
|
||||||
|
$createResponse = makeRequest($createUrl, $createData, $apiKey);
|
||||||
|
file_put_contents('debug.log', "Create Response: " . json_encode($createResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if (!$createResponse['success']) {
|
||||||
|
$errorMessage = isset($createResponse['meta']['message']) ? $createResponse['meta']['message'] : 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nella creazione del tracking: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Recupera i dettagli del tracking con riprova
|
||||||
|
$getUrl = 'https://api.trackingmore.com/v4/trackings/get?tracking_number=' . urlencode($trackingNumber);
|
||||||
|
$maxAttempts = 3;
|
||||||
|
$delaySeconds = 5;
|
||||||
|
|
||||||
|
for ($attempt = 1; $attempt <= $maxAttempts; $attempt++) {
|
||||||
|
$trackResponse = makeRequest($getUrl, [], $apiKey, 'GET');
|
||||||
|
file_put_contents('debug.log', "Track Response (Attempt $attempt): " . json_encode($trackResponse) . "\n", FILE_APPEND);
|
||||||
|
|
||||||
|
if ($trackResponse['success'] && !empty($trackResponse['data'])) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($attempt < $maxAttempts) {
|
||||||
|
sleep($delaySeconds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$trackResponse['success']) {
|
||||||
|
$errorMessage = isset($trackResponse['meta']['message']) ? $trackResponse['meta']['message'] : 'Errore sconosciuto';
|
||||||
|
sendResponse(['success' => false, 'message' => 'Errore nel recupero delle informazioni: ' . $errorMessage]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$trackingInfo = $trackResponse['data'] ?? null;
|
||||||
|
if (!$trackingInfo) {
|
||||||
|
// Se ci sono più corrieri rilevati, restituisci una lista per la tendina
|
||||||
|
if (count($couriers) > 1) {
|
||||||
|
$possibleCarriers = array_map(function ($courier) {
|
||||||
|
return ['code' => $courier['courier_code'], 'name' => $courier['courier_name']];
|
||||||
|
}, $couriers);
|
||||||
|
sendResponse([
|
||||||
|
'success' => false,
|
||||||
|
'message' => 'Dati non trovati. Seleziona un corriere tra quelli rilevati.',
|
||||||
|
'possibleCarriers' => $possibleCarriers
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
sendResponse(['success' => false, 'message' => 'Nessuna informazione di tracking trovata']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Estrai la data di consegna e il firmatario
|
||||||
|
$deliveryDate = 'Non disponibile';
|
||||||
|
$signedBy = 'Non disponibile';
|
||||||
|
foreach ($trackingInfo['trackinfo'] as $checkpoint) {
|
||||||
|
if ($checkpoint['status'] === 'delivered') {
|
||||||
|
$deliveryDate = $checkpoint['Date'];
|
||||||
|
$signedBy = $checkpoint['signed_by'] ?? 'Non disponibile';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restituisci i dati al frontend
|
||||||
|
sendResponse([
|
||||||
|
'success' => true,
|
||||||
|
'deliveryDate' => $deliveryDate,
|
||||||
|
'signedBy' => $signedBy,
|
||||||
|
'carrierName' => $courierName
|
||||||
|
]);
|
||||||
@ -20,12 +20,19 @@
|
|||||||
padding: 20px;
|
padding: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Definizione delle dimensioni */
|
||||||
/* Definizione delle dimensioni */
|
/* Definizione delle dimensioni */
|
||||||
.btn-small {
|
.btn-small {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
|
display: flex;
|
||||||
|
/* Aggiunto */
|
||||||
|
justify-content: center;
|
||||||
|
/* Aggiunto */
|
||||||
|
align-items: center;
|
||||||
|
/* Aggiunto */
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-medium {
|
.btn-medium {
|
||||||
@ -33,6 +40,12 @@
|
|||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
min-width: 130px;
|
min-width: 130px;
|
||||||
min-height: 45px;
|
min-height: 45px;
|
||||||
|
display: flex;
|
||||||
|
/* Aggiunto */
|
||||||
|
justify-content: center;
|
||||||
|
/* Aggiunto */
|
||||||
|
align-items: center;
|
||||||
|
/* Aggiunto */
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-large {
|
.btn-large {
|
||||||
@ -40,6 +53,12 @@
|
|||||||
padding: 14px 28px;
|
padding: 14px 28px;
|
||||||
min-width: 180px;
|
min-width: 180px;
|
||||||
min-height: 60px;
|
min-height: 60px;
|
||||||
|
display: flex;
|
||||||
|
/* Aggiunto */
|
||||||
|
justify-content: center;
|
||||||
|
/* Aggiunto */
|
||||||
|
align-items: center;
|
||||||
|
/* Aggiunto */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stile della barra di ricerca */
|
/* Stile della barra di ricerca */
|
||||||
|
|||||||
1006
public/userarea/import_edit.php
Normal file
1006
public/userarea/import_edit.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -51,9 +51,7 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
border: 1px solid #dee2e6;
|
border: 1px solid #dee2e6;
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
/* Larghezza minima per tutte le colonne */
|
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
/* Larghezza massima iniziale */
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
@ -62,7 +60,6 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
.table th:first-child,
|
.table th:first-child,
|
||||||
.table td:first-child {
|
.table td:first-child {
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
/* Colonna "Seleziona" più stretta */
|
|
||||||
max-width: 50px;
|
max-width: 50px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +70,6 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handle di ridimensionamento */
|
|
||||||
.table th .resize-handle {
|
.table th .resize-handle {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
@ -199,16 +195,7 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData
|
body: formData
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => response.json())
|
||||||
return response.text().then(text => {
|
|
||||||
console.log('Risposta grezza:', text);
|
|
||||||
try {
|
|
||||||
return JSON.parse(text);
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('Risposta non valida: ' + text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.then(data => {
|
.then(data => {
|
||||||
loader.style.display = 'none';
|
loader.style.display = 'none';
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
@ -218,6 +205,9 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
let html = `
|
let html = `
|
||||||
<form id="selectRowsForm" action="import_edit.php" method="POST">
|
<form id="selectRowsForm" action="import_edit.php" method="POST">
|
||||||
<input type="hidden" name="template_id" value="${data.template_id}">
|
<input type="hidden" name="template_id" value="${data.template_id}">
|
||||||
|
<input type="hidden" name="columns" value='${JSON.stringify(data.columns)}'>
|
||||||
|
<input type="hidden" name="rows" value='${JSON.stringify(data.rows)}'>
|
||||||
|
<input type="hidden" name="filename" value="${data.filename}">
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<input type="text" id="searchInput" class="form-control" placeholder="Cerca nelle righe...">
|
<input type="text" id="searchInput" class="form-control" placeholder="Cerca nelle righe...">
|
||||||
</div>
|
</div>
|
||||||
@ -256,12 +246,11 @@ error_log("Loaded template: " . print_r($template, true));
|
|||||||
const startWidth = th.offsetWidth;
|
const startWidth = th.offsetWidth;
|
||||||
|
|
||||||
const onMouseMove = (e) => {
|
const onMouseMove = (e) => {
|
||||||
const newWidth = Math.max(50, startWidth + (e.clientX - startX)); // Min 50px
|
const newWidth = Math.max(50, startWidth + (e.clientX - startX));
|
||||||
th.style.width = `${newWidth}px`;
|
th.style.width = `${newWidth}px`;
|
||||||
th.style.minWidth = `${newWidth}px`;
|
th.style.minWidth = `${newWidth}px`;
|
||||||
th.style.maxWidth = `${newWidth}px`;
|
th.style.maxWidth = `${newWidth}px`;
|
||||||
|
|
||||||
// Aggiorna anche le celle della colonna corrispondente
|
|
||||||
const cells = document.querySelectorAll(`.table td:nth-child(${index + 1})`);
|
const cells = document.querySelectorAll(`.table td:nth-child(${index + 1})`);
|
||||||
cells.forEach(cell => {
|
cells.forEach(cell => {
|
||||||
cell.style.width = `${newWidth}px`;
|
cell.style.width = `${newWidth}px`;
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
140
public/userarea/photos_popup.php
Normal file
140
public/userarea/photos_popup.php
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
// photos_popup.php
|
||||||
|
include('include/headscript.php');
|
||||||
|
// Includi l'autoloader di Composer
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
use Endroid\QrCode\Color\Color;
|
||||||
|
use Endroid\QrCode\Encoding\Encoding;
|
||||||
|
use Endroid\QrCode\ErrorCorrectionLevel;
|
||||||
|
use Endroid\QrCode\QrCode;
|
||||||
|
use Endroid\QrCode\RoundBlockSizeMode;
|
||||||
|
use Endroid\QrCode\Writer\PngWriter;
|
||||||
|
|
||||||
|
$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']);
|
||||||
|
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']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$idriga = $row['iddatadb'];
|
||||||
|
$sampleCode = $row['sample_code'] ?? '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);
|
||||||
|
|
||||||
|
// Definisci il percorso base per le foto
|
||||||
|
$photoBasePath = '../photostrf/';
|
||||||
|
|
||||||
|
// Genera l'URL per il QR code
|
||||||
|
$baseUrl = "http://localhost/trf_certest/public/userarea/"; // Sostituisci con il tuo dominio
|
||||||
|
$uploadUrl = $baseUrl . "upload_photos_mobile.php?iddatadb=" . $iddatadb;
|
||||||
|
|
||||||
|
// 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";
|
||||||
|
|
||||||
|
$writer = new PngWriter();
|
||||||
|
|
||||||
|
// Crea il QR code usando il costruttore
|
||||||
|
$qrCode = new QrCode(
|
||||||
|
data: $uploadUrl,
|
||||||
|
encoding: new Encoding('UTF-8'),
|
||||||
|
errorCorrectionLevel: ErrorCorrectionLevel::Low,
|
||||||
|
size: 150,
|
||||||
|
margin: 10,
|
||||||
|
roundBlockSizeMode: RoundBlockSizeMode::Margin,
|
||||||
|
foregroundColor: new Color(0, 0, 0),
|
||||||
|
backgroundColor: new Color(255, 255, 255)
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $writer->write($qrCode);
|
||||||
|
$result->saveToFile($qrCodeFile);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="popup-content">
|
||||||
|
<h3>Gestione Foto</h3>
|
||||||
|
<p><strong>ID Riga:</strong> <?= htmlspecialchars($idriga) ?></p>
|
||||||
|
<p><strong>Sample Code:</strong> <?= htmlspecialchars($sampleCode) ?></p>
|
||||||
|
|
||||||
|
<!-- QR Code per il caricamento da mobile -->
|
||||||
|
<div style="text-align: center; margin-bottom: 20px;">
|
||||||
|
<p>Scansiona il QR code per caricare foto dal tuo telefono:</p>
|
||||||
|
<img src="../photostrf/qrcodes/qrcode_<?= $iddatadb ?>.png" alt="QR Code" style="max-width: 150px;">
|
||||||
|
<p style="margin-top: 10px;">
|
||||||
|
<a href="<?= htmlspecialchars($uploadUrl) ?>" target="_blank"><?= htmlspecialchars($uploadUrl) ?></a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Area drag-and-drop per il caricamento delle foto -->
|
||||||
|
<div id="dropArea" style="border: 2px dashed #ccc; padding: 20px; text-align: center; margin-bottom: 20px;">
|
||||||
|
<p>Trascina qui le foto o clicca per selezionarle</p>
|
||||||
|
<input type="file" id="photoInput" multiple accept="image/*" style="display: none;">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Elenco delle foto -->
|
||||||
|
<div id="photosList">
|
||||||
|
<?php if (empty($photos)): ?>
|
||||||
|
<p>Nessuna foto presente.</p>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php foreach ($photos as $photo): ?>
|
||||||
|
<?php
|
||||||
|
$filePath = $photoBasePath . $photo['file_path'];
|
||||||
|
$fileExists = file_exists($filePath);
|
||||||
|
?>
|
||||||
|
<div class="photo-item" data-photo-id="<?= $photo['id'] ?>" style="display: flex; align-items: center; margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 10px;">
|
||||||
|
<div style="flex: 1;">
|
||||||
|
<?php if ($fileExists): ?>
|
||||||
|
<img src="../photostrf/<?= htmlspecialchars($photo['file_path']) ?>" alt="<?= htmlspecialchars($photo['file_name']) ?>" style="max-width: 100px; max-height: 100px; margin-right: 10px;">
|
||||||
|
<?php else: ?>
|
||||||
|
<p style="color: red;">[File non trovato]</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<p style="margin: 0;">
|
||||||
|
<strong>Nome:</strong> <?= htmlspecialchars($photo['file_name']) ?><br>
|
||||||
|
<strong>Caricata il:</strong> <?= htmlspecialchars($photo['uploaded_at']) ?><br>
|
||||||
|
<strong>Descrizione:</strong> <?= htmlspecialchars($photo['description'] ?? 'Nessuna descrizione') ?>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<button class="delete-photo-btn" data-photo-id="<?= $photo['id'] ?>" style="background: none; border: none; color: #dc3545; cursor: pointer;">
|
||||||
|
<i class="fas fa-trash"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.photo-item {
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-item:hover {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
#dropArea.highlight {
|
||||||
|
border-color: #28a745;
|
||||||
|
background-color: #e9ecef;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -10,7 +10,7 @@ session_start();
|
|||||||
// Includi PHPSpreadsheet
|
// Includi PHPSpreadsheet
|
||||||
require_once '../../vendor/autoload.php';
|
require_once '../../vendor/autoload.php';
|
||||||
|
|
||||||
$response = ['error' => '', 'rows' => [], 'columns' => [], 'template_id' => 0];
|
$response = ['error' => '', 'rows' => [], 'columns' => [], 'template_id' => 0, 'filename' => ''];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['excel_file'])) {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['excel_file'])) {
|
||||||
@ -22,7 +22,30 @@ try {
|
|||||||
$fileError = $file['error'];
|
$fileError = $file['error'];
|
||||||
|
|
||||||
if ($fileError === UPLOAD_ERR_OK) {
|
if ($fileError === UPLOAD_ERR_OK) {
|
||||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file['tmp_name']);
|
// Recupera l'ID dell'utente loggato (assumiamo sia disponibile in $iduserlogin)
|
||||||
|
if (!isset($iduserlogin)) {
|
||||||
|
$iduserlogin = 1; // Valore di default
|
||||||
|
error_log("Warning: iduserlogin non definito, usando 1 come default");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Genera il nome del file rinominato
|
||||||
|
$timestamp = date('YmdHis');
|
||||||
|
$originalFilename = basename($file['name']);
|
||||||
|
$newFilename = "{$iduserlogin}-{$timestamp}-{$originalFilename}";
|
||||||
|
$importFolder = __DIR__ . '/imported_trf/';
|
||||||
|
if (!file_exists($importFolder)) {
|
||||||
|
mkdir($importFolder, 0777, true);
|
||||||
|
}
|
||||||
|
$destination = $importFolder . $newFilename;
|
||||||
|
|
||||||
|
// Sposta il file
|
||||||
|
if (!move_uploaded_file($file['tmp_name'], $destination)) {
|
||||||
|
throw new Exception("Errore durante lo spostamento del file in $destination");
|
||||||
|
}
|
||||||
|
error_log("File spostato con successo in: $destination");
|
||||||
|
|
||||||
|
// Carica il file rinominato con PHPSpreadsheet
|
||||||
|
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($destination);
|
||||||
$worksheet = $spreadsheet->getActiveSheet();
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
$highestRow = $worksheet->getHighestRow();
|
$highestRow = $worksheet->getHighestRow();
|
||||||
$highestColumn = $worksheet->getHighestColumn();
|
$highestColumn = $worksheet->getHighestColumn();
|
||||||
@ -72,6 +95,7 @@ try {
|
|||||||
$response['rows'] = $excelData;
|
$response['rows'] = $excelData;
|
||||||
$response['columns'] = $headerRowData; // Usa gli header reali
|
$response['columns'] = $headerRowData; // Usa gli header reali
|
||||||
$response['template_id'] = $template_id;
|
$response['template_id'] = $template_id;
|
||||||
|
$response['filename'] = $newFilename; // Aggiungi il nome del file rinominato
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$response['error'] = "Errore nell'upload del file: Codice errore $fileError.";
|
$response['error'] = "Errore nell'upload del file: Codice errore $fileError.";
|
||||||
|
|||||||
47
public/userarea/save_edited_data.php
Normal file
47
public/userarea/save_edited_data.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$response = ['success' => false, 'message' => ''];
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['iddatadb'])) {
|
||||||
|
throw new Exception('Richiesta non valida');
|
||||||
|
}
|
||||||
|
|
||||||
|
$iddatadb = intval($_POST['iddatadb']);
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
// Campi non modificabili
|
||||||
|
$excludeFields = ['importdate', 'status', 'user_id', 'filename_import', 'importreferencecode', 'limscode'];
|
||||||
|
|
||||||
|
// Prepara i dati da aggiornare
|
||||||
|
$updates = [];
|
||||||
|
$values = [];
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
if ($key !== 'iddatadb' && !in_array($key, $excludeFields)) {
|
||||||
|
$updates[] = "$key = ?";
|
||||||
|
$values[] = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$values[] = $iddatadb;
|
||||||
|
|
||||||
|
if (empty($updates)) {
|
||||||
|
throw new Exception('Nessun dato da aggiornare');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE datadb SET " . implode(', ', $updates) . " WHERE iddatadb = ?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($values);
|
||||||
|
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Riga aggiornata con successo';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$response['message'] = $e->getMessage();
|
||||||
|
error_log("Errore in save_edited_row.php: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
exit;
|
||||||
44
public/userarea/save_edited_row.php
Normal file
44
public/userarea/save_edited_row.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$response = ['success' => false, 'message' => ''];
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_POST['iddatadb'])) {
|
||||||
|
throw new Exception('Richiesta non valida');
|
||||||
|
}
|
||||||
|
|
||||||
|
$iddatadb = intval($_POST['iddatadb']);
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
// Prepara i dati da aggiornare
|
||||||
|
$updates = [];
|
||||||
|
$values = [];
|
||||||
|
foreach ($_POST as $key => $value) {
|
||||||
|
if ($key !== 'iddatadb') {
|
||||||
|
$updates[] = "$key = ?";
|
||||||
|
$values[] = htmlspecialchars($value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$values[] = $iddatadb;
|
||||||
|
|
||||||
|
if (empty($updates)) {
|
||||||
|
throw new Exception('Nessun dato da aggiornare');
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE datadb SET " . implode(', ', $updates) . " WHERE iddatadb = ?";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($values);
|
||||||
|
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Riga aggiornata con successo';
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$response['message'] = $e->getMessage();
|
||||||
|
error_log("Errore in save_edited_row.php: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($response);
|
||||||
|
exit;
|
||||||
@ -5,9 +5,9 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<div>
|
<div>
|
||||||
<p class="mb-0 text-white">Revenue</p>
|
<p class="mb-0 text-white">Imported XLS</p>
|
||||||
<h4 class="my-1 text-white">$4805</h4>
|
<h4 class="my-1 text-white">4805</h4>
|
||||||
<p class="mb-0 font-13 text-white"><i class="bx bxs-up-arrow align-middle"></i>$34 from last week</p>
|
<p class="mb-0 font-13 text-white"><i class="bx bxs-up-arrow align-middle"></i>34 from last week</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="widgets-icons bg-white text-success ms-auto"><i class="bx bxs-wallet"></i>
|
<div class="widgets-icons bg-white text-success ms-auto"><i class="bx bxs-wallet"></i>
|
||||||
</div>
|
</div>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<p class="mb-0 text-dark">Total Customers</p>
|
<p class="mb-0 text-dark">Total Customers</p>
|
||||||
<h4 class="my-1 text-dark">8.4K</h4>
|
<h4 class="my-1 text-dark">8.4K</h4>
|
||||||
<p class="mb-0 font-13 text-dark"><i class="bx bxs-up-arrow align-middle"></i>$24 from last week</p>
|
<p class="mb-0 font-13 text-dark"><i class="bx bxs-up-arrow align-middle"></i>24 from last week</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="widgets-icons bg-white text-dark ms-auto"><i class="bx bxs-group"></i>
|
<div class="widgets-icons bg-white text-dark ms-auto"><i class="bx bxs-group"></i>
|
||||||
</div>
|
</div>
|
||||||
@ -35,9 +35,9 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<div>
|
<div>
|
||||||
<p class="mb-0 text-white">Store Visitors</p>
|
<p class="mb-0 text-white">Exported to LIMS</p>
|
||||||
<h4 class="my-1 text-white">59K</h4>
|
<h4 class="my-1 text-white">59K</h4>
|
||||||
<p class="mb-0 font-13 text-white"><i class="bx bxs-down-arrow align-middle"></i>$34 from last week</p>
|
<p class="mb-0 font-13 text-white"><i class="bx bxs-down-arrow align-middle"></i>34 from last week</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="widgets-icons bg-white text-danger ms-auto"><i class="bx bxs-binoculars"></i>
|
<div class="widgets-icons bg-white text-danger ms-auto"><i class="bx bxs-binoculars"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
79
public/userarea/upload_photo.php
Normal file
79
public/userarea/upload_photo.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
// upload_photo.php
|
||||||
|
include('include/headscript.php');
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST' || !isset($_FILES['photo']) || !isset($_POST['iddatadb'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Richiesta non valida']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$iddatadb = intval($_POST['iddatadb']);
|
||||||
|
$photo = $_FILES['photo'];
|
||||||
|
|
||||||
|
// Verifica che l'utente loggato esista in auth_users
|
||||||
|
$db = DBHandlerSelect::getInstance();
|
||||||
|
$pdo = $db->getConnection();
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM auth_users WHERE id = ?");
|
||||||
|
$stmt->execute([$iduserlogin]);
|
||||||
|
$userExists = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
if (!$userExists) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Utente non valido']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Usa un percorso assoluto per la cartella photostrf
|
||||||
|
$uploadDir = realpath(__DIR__ . '/../photostrf') . '/';
|
||||||
|
if (!is_dir($uploadDir)) {
|
||||||
|
if (!mkdir($uploadDir, 0755, true)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Impossibile creare la cartella photostrf']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica i permessi della cartella
|
||||||
|
if (!is_writable($uploadDir)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'La cartella photostrf non è scrivibile']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica che il file sia un'immagine
|
||||||
|
$allowedTypes = ['image/jpeg', 'image/png', 'image/gif'];
|
||||||
|
if (!in_array($photo['type'], $allowedTypes)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Il file deve essere un\'immagine (JPEG, PNG, GIF)']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica che il file temporaneo esista
|
||||||
|
if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'File temporaneo non valido']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rinomina il file: idriga-timestamp-nomeoriginale.estensione
|
||||||
|
$timestamp = date('YmdHis');
|
||||||
|
$originalName = pathinfo($photo['name'], PATHINFO_FILENAME);
|
||||||
|
$extension = pathinfo($photo['name'], PATHINFO_EXTENSION);
|
||||||
|
$newFileName = "{$iddatadb}-{$timestamp}-{$originalName}.{$extension}";
|
||||||
|
$destination = $uploadDir . $newFileName;
|
||||||
|
|
||||||
|
// Debug: verifica i percorsi
|
||||||
|
error_log("Upload directory: $uploadDir");
|
||||||
|
error_log("Destination: $destination");
|
||||||
|
error_log("Temp file: " . $photo['tmp_name']);
|
||||||
|
|
||||||
|
// Salva il file
|
||||||
|
if (!move_uploaded_file($photo['tmp_name'], $destination)) {
|
||||||
|
$error = error_get_last();
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Errore durante il caricamento del file: ' . (isset($error['message']) ? $error['message'] : 'Sconosciuto')]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Salva il riferimento nel database
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO datadb_photos (iddatadb, file_path, file_name, uploaded_by) VALUES (?, ?, ?, ?)");
|
||||||
|
$stmt->execute([$iddatadb, $newFileName, $photo['name'], $iduserlogin]);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Foto caricata con successo']);
|
||||||
145
public/userarea/upload_photos_mobile.php
Normal file
145
public/userarea/upload_photos_mobile.php
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?php
|
||||||
|
// upload_photos_mobile.php
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
|
$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) {
|
||||||
|
die('Riga non trovata');
|
||||||
|
}
|
||||||
|
|
||||||
|
$idriga = $row['iddatadb'];
|
||||||
|
$sampleCode = $row['sample_code'] ?? 'Non disponibile';
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="it">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Carica Foto da Mobile</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
padding: 20px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-area {
|
||||||
|
border: 2px dashed #ccc;
|
||||||
|
padding: 20px;
|
||||||
|
margin: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-area.highlight {
|
||||||
|
border-color: #28a745;
|
||||||
|
background-color: #e9ecef;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.photo-item img {
|
||||||
|
max-width: 100px;
|
||||||
|
max-height: 100px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h2>Carica Foto per ID Riga: <?= htmlspecialchars($idriga) ?></h2>
|
||||||
|
<p><strong>Sample Code:</strong> <?= htmlspecialchars($sampleCode) ?></p>
|
||||||
|
|
||||||
|
<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 -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const uploadArea = document.getElementById('uploadArea');
|
||||||
|
const photoInput = document.getElementById('photoInput');
|
||||||
|
const photosList = document.getElementById('photosList');
|
||||||
|
|
||||||
|
// Carica le foto esistenti all'avvio
|
||||||
|
loadPhotos();
|
||||||
|
|
||||||
|
// Gestione del click sull'area di upload
|
||||||
|
uploadArea.addEventListener('click', () => {
|
||||||
|
photoInput.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gestione del caricamento delle foto
|
||||||
|
photoInput.addEventListener('change', () => {
|
||||||
|
handleFiles(photoInput.files);
|
||||||
|
});
|
||||||
|
|
||||||
|
async function handleFiles(files) {
|
||||||
|
for (const file of files) {
|
||||||
|
if (!file.type.startsWith('image/')) {
|
||||||
|
alert('Per favore, carica solo immagini!');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('photo', file);
|
||||||
|
formData.append('iddatadb', '<?= $iddatadb ?>');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('upload_photo.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
const result = await response.json();
|
||||||
|
|
||||||
|
if (result.success) {
|
||||||
|
loadPhotos(); // Ricarica le foto
|
||||||
|
} else {
|
||||||
|
alert('Errore durante il caricamento: ' + result.message);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert('Errore durante il caricamento: ' + error.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Funzione per caricare le foto esistenti
|
||||||
|
async function loadPhotos() {
|
||||||
|
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;
|
||||||
|
} catch (error) {
|
||||||
|
photosList.innerHTML = `<p>Errore durante il caricamento delle foto: ${error.message}</p>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
Binary file not shown.
0
trackingmore_response.json
Normal file
0
trackingmore_response.json
Normal file
Loading…
x
Reference in New Issue
Block a user