Skip to content

Commit 651f643

Browse files
committed
added export functionalities to the website
updated translations fixed cleartext error in the Android application
1 parent 08c0839 commit 651f643

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2264
-146
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<network-security-config>
3-
<domain-config cleartextTrafficPermitted="true">
4-
<!-- Allow HTTP traffic to local/private IP addresses for development -->
5-
<domain includeSubdomains="false">localhost</domain>
6-
<domain includeSubdomains="false">127.0.0.1</domain>
7-
<domain includeSubdomains="false">192.168.1.188</domain>
8-
<domain includeSubdomains="false">10.0.2.2</domain>
9-
</domain-config>
3+
<!-- Allow cleartext traffic globally for development/testing -->
4+
<base-config cleartextTrafficPermitted="true">
5+
<trust-anchors>
6+
<certificates src="system"/>
7+
</trust-anchors>
8+
</base-config>
109
</network-security-config>

WebInterface/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ RUN apt-get update && apt-get install -y \
1717
php8.1-mbstring \
1818
php8.1-xml \
1919
php8.1-zip \
20+
php8.1-gd \
21+
php8.1-intl \
22+
unzip \
23+
git \
2024
mysql-server \
2125
mysql-client \
2226
wget \
@@ -25,6 +29,9 @@ RUN apt-get update && apt-get install -y \
2529
nano \
2630
&& rm -rf /var/lib/apt/lists/*
2731

32+
# Install Composer for PHP dependency management
33+
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
34+
2835
# Install phpMyAdmin
2936
RUN wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-all-languages.tar.gz \
3037
&& tar xzf phpMyAdmin-5.2.1-all-languages.tar.gz \
@@ -44,6 +51,10 @@ COPY mysql/my.cnf /etc/mysql/conf.d/custom.cnf
4451
# Copy application source code
4552
COPY src/ /var/www/html/
4653

54+
# Copy composer.json and install dependencies
55+
COPY composer.json /var/www/html/composer.json
56+
RUN cd /var/www/html && composer install --no-dev --optimize-autoloader --no-interaction || echo "No composer dependencies to install"
57+
4758
# Copy database initialization script
4859
COPY database/init.sql /tmp/init.sql
4960

WebInterface/composer.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "ai-multibarcode-capture/webinterface",
3+
"description": "Web interface for AI MultiBarcode Capture with Excel export functionality",
4+
"type": "project",
5+
"require": {
6+
"php": ">=7.4",
7+
"phpoffice/phpspreadsheet": "^1.29"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"App\\": "src/"
12+
}
13+
}
14+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
// Debug version of export.php with detailed error reporting
3+
header('Content-Type: application/json');
4+
header('Access-Control-Allow-Origin: *');
5+
header('Access-Control-Allow-Methods: POST, OPTIONS');
6+
header('Access-Control-Allow-Headers: Content-Type, Authorization, X-Requested-With');
7+
8+
// Handle preflight requests
9+
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
10+
http_response_code(200);
11+
exit();
12+
}
13+
14+
// Enable error reporting
15+
error_reporting(E_ALL);
16+
ini_set('display_errors', 0); // Don't display errors to prevent header issues
17+
ini_set('log_errors', 1);
18+
19+
$debug_info = [
20+
'timestamp' => date('Y-m-d H:i:s'),
21+
'method' => $_SERVER['REQUEST_METHOD'],
22+
'step' => 'start',
23+
'errors' => []
24+
];
25+
26+
try {
27+
$debug_info['step'] = 'reading_input';
28+
$input = file_get_contents('php://input');
29+
$debug_info['raw_input'] = $input;
30+
31+
$debug_info['step'] = 'parsing_json';
32+
$data = json_decode($input, true);
33+
$debug_info['parsed_data'] = $data;
34+
35+
if (!$data) {
36+
throw new Exception('Invalid JSON input: ' . json_last_error_msg());
37+
}
38+
39+
$debug_info['step'] = 'validating_input';
40+
if (!isset($data['session_ids']) || !isset($data['format'])) {
41+
throw new Exception('Missing session_ids or format parameter');
42+
}
43+
44+
$debug_info['step'] = 'connecting_database';
45+
require_once '../config/database.php';
46+
47+
$debug_info['step'] = 'creating_database_object';
48+
$db = new Database();
49+
50+
$debug_info['step'] = 'getting_connection';
51+
$connection = $db->getConnection();
52+
53+
$debug_info['step'] = 'preparing_query';
54+
$sessionIds = $data['session_ids'];
55+
$placeholders = str_repeat('?,', count($sessionIds) - 1) . '?';
56+
57+
$query = "
58+
SELECT
59+
b.id,
60+
b.value as barcode_value,
61+
b.symbology,
62+
b.symbology_name,
63+
b.quantity,
64+
b.timestamp as scan_date,
65+
COALESCE(b.processed, 0) as processed,
66+
COALESCE(b.notes, '') as notes,
67+
s.device_info,
68+
s.device_ip,
69+
s.session_timestamp as session_created
70+
FROM barcodes b
71+
JOIN capture_sessions s ON b.session_id = s.id
72+
WHERE b.session_id IN ($placeholders)
73+
ORDER BY s.session_timestamp DESC, b.timestamp ASC
74+
LIMIT 10
75+
";
76+
77+
$debug_info['step'] = 'executing_query';
78+
$debug_info['query'] = $query;
79+
$debug_info['session_ids'] = $sessionIds;
80+
81+
$stmt = $connection->prepare($query);
82+
$stmt->execute($sessionIds);
83+
84+
$debug_info['step'] = 'fetching_results';
85+
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
86+
$debug_info['result_count'] = count($results);
87+
$debug_info['sample_results'] = array_slice($results, 0, 2); // First 2 results for debugging
88+
89+
$debug_info['step'] = 'success';
90+
$debug_info['status'] = 'Export would work with ' . count($results) . ' records';
91+
92+
} catch (Exception $e) {
93+
$debug_info['step'] = 'error';
94+
$debug_info['error_message'] = $e->getMessage();
95+
$debug_info['error_trace'] = $e->getTraceAsString();
96+
$debug_info['errors'][] = [
97+
'message' => $e->getMessage(),
98+
'file' => $e->getFile(),
99+
'line' => $e->getLine()
100+
];
101+
}
102+
103+
// Return debug information as JSON
104+
echo json_encode($debug_info, JSON_PRETTY_PRINT);
105+
?>

0 commit comments

Comments
 (0)