EPCQR Modul - Test & Debug'; // 1. Modul-Status prüfen print '

1. Modul-Status

'; print ''; print ''; // 2. Modul-Konfiguration prüfen print ''; print ''; print '
Modul aktiviert'; print isModEnabled('epcqr') ? '✓ Ja' : '✗ Nein'; print '
Substitutionen aktiviert'; $module_parts = $conf->modules_parts; $subst_active = isset($module_parts['substitutions']['epcqr']) || (isset($module_parts['substitutions']) && is_array($module_parts['substitutions']) && in_array('epcqr', $module_parts['substitutions'])); print $subst_active ? '✓ Ja' : '✗ Nein (in modEpcqr.class.php aktivieren!)'; print '
Hooks aktiviert'; $hooks_active = isset($module_parts['hooks']) && isset($module_parts['hooks']['epcqr']); print $hooks_active ? '✓ Ja' : '✗ Nein'; if ($hooks_active) { print '
Hooks: '.implode(', ', $module_parts['hooks']['epcqr']); } print '
'; // 3. Dateien prüfen print '

2. Dateien vorhanden

'; print ''; $files = array( 'QR-Code Generator' => __DIR__.'/lib/qrcode.class.php', 'Substitutionen' => __DIR__.'/core/substitutions/functions_epcqr.lib.php', 'Hook-Klasse' => __DIR__.'/class/actions_epcqr.class.php', 'Hilfsfunktionen' => __DIR__.'/lib/epcqr.lib.php', ); foreach ($files as $name => $file) { print ''; } print '
'.$name.''; if (file_exists($file)) { print '✓ Vorhanden ('.$file.')'; } else { print '✗ Fehlt! ('.$file.')'; } print '
'; // 4. Extrafelder prüfen print '

3. Extrafelder

'; print ''; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $extrafields = new ExtraFields($db); $extrafields->fetch_name_optionals_label('facture'); $required_fields = array('qrcode', 'qrcodepfad', 'qrcodepath'); foreach ($required_fields as $field) { print ''; } print '
'.$field.''; if (isset($extrafields->attributes['facture']['label'][$field])) { print '✓ Vorhanden'; print ' - Typ: '.$extrafields->attributes['facture']['type'][$field]; } else { print '✗ Fehlt! (SQL-Update ausführen!)'; } print '
'; // 5. Verzeichnisse prüfen print '

4. Verzeichnisse

'; print ''; $qrCodeDir = $conf->epcqr->dir_output.'/qrcodes'; print ''; print '
QR-Code Cache'; if (is_dir($qrCodeDir)) { print '✓ Vorhanden ('.$qrCodeDir.')'; if (is_writable($qrCodeDir)) { print ' - Beschreibbar'; } else { print ' - Nicht beschreibbar!'; } } else { print '⚠ Fehlt (wird automatisch erstellt)'; } print '
'; // 6. Test: QR-Code generieren print '

5. Test: QR-Code generieren

'; require_once __DIR__.'/lib/qrcode.class.php'; try { $qrGen = new QRCodeGenerator($db); $testPath = $qrGen->generateEPCQRCode( 'Test Firma', 'DE89370400440532013000', 'COBADEFFXXX', 99.99, 'TEST-001' ); print '

✓ QR-Code erfolgreich generiert!

'; print '

Pfad: '.$testPath.'

'; if (file_exists($testPath)) { print '

'; } } catch (Exception $e) { print '

✗ Fehler: '.$e->getMessage().'

'; } // 7. Letzte Rechnungen mit QR-Codes prüfen print '

6. Letzte 5 Rechnungen mit QR-Codes

'; $sql = "SELECT f.rowid, f.ref, f.total_ttc, f.datef"; $sql .= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.entity = ".((int) $conf->entity); $sql .= " ORDER BY f.datef DESC"; $sql .= " LIMIT 5"; $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; while ($obj = $db->fetch_object($resql)) { $invoice = new Facture($db); $invoice->fetch($obj->rowid); $invoice->fetch_optionals(); print ''; print ''; print ''; $qrPath = isset($invoice->array_options['options_qrcodepath']) ? $invoice->array_options['options_qrcodepath'] : ''; print ''; } else { print 'Nicht gesetzt'; print ''; } print ''; } print '
RechnungBetragQR-Code PathDatei existiert?
'.$invoice->getNomUrl(1).''.price($obj->total_ttc).''; if (!empty($qrPath)) { print $qrPath; print ''; if (file_exists($qrPath)) { print '✓ Ja'; } else { print '✗ Nein'; } print '-
'; } else { print '

Keine Rechnungen gefunden.

'; } } else { print '

SQL-Fehler: '.$db->lasterror().'

'; } // 8. Logs prüfen print '

7. Letzte Log-Einträge (EPCQR)

'; $logFile = DOL_DATA_ROOT.'/dolibarr.log'; if (file_exists($logFile)) { // Nur die letzten 500 Zeilen lesen um Memory-Probleme zu vermeiden $epcqrLogs = array(); $output = array(); exec('tail -500 '.escapeshellarg($logFile).' 2>/dev/null', $output); foreach (array_reverse($output) as $line) { if (stripos($line, 'EPCQR') !== false || stripos($line, 'epcqr') !== false) { $epcqrLogs[] = $line; if (count($epcqrLogs) >= 10) break; } } if (!empty($epcqrLogs)) { print '
';
        foreach (array_reverse($epcqrLogs) as $log) {
            print htmlspecialchars($log)."\n";
        }
        print '
'; } else { print '

Keine EPCQR-Log-Einträge in den letzten 500 Zeilen gefunden.

'; } } else { print '

Log-Datei nicht gefunden: '.$logFile.'

'; } // 9. Anleitung print '

8. Nächste Schritte

'; print '
'; print '
    '; print '
  1. Modul neu aktivieren: Wenn Substitutionen oder Hooks rot sind → Modul deaktivieren und wieder aktivieren
  2. '; print '
  3. Rechnung validieren: Erstellen Sie eine Test-Rechnung und validieren Sie diese
  4. '; print '
  5. ODT generieren: Template mit {qrcode} erstellen und Dokument generieren
  6. '; print '
  7. Logs prüfen: Schauen Sie in documents/dolibarr.log nach EPCQR-Einträgen
  8. '; print '
'; print '
'; print '

9. Schnelltest: ODT-Bildverarbeitung

'; print '
'; print ''; print '

Test-Rechnung ID:

'; print ''; print '
'; if (GETPOST('action') == 'test_odt' && GETPOST('invoice_id')) { $invoice_id = GETPOST('invoice_id', 'int'); print '

Test-Ergebnis:

'; $invoice = new Facture($db); if ($invoice->fetch($invoice_id) > 0) { $invoice->fetch_optionals(); print '

Rechnung: '.$invoice->ref.'

'; // QR-Code Path prüfen $qrPath = isset($invoice->array_options['options_qrcodepath']) ? $invoice->array_options['options_qrcodepath'] : ''; print '

QR-Code Path: '.($qrPath ? $qrPath : 'Nicht gesetzt!').'

'; if (!empty($qrPath) && file_exists($qrPath)) { print '

✓ QR-Code-Datei existiert

'; // Test: Bilddaten sammeln require_once __DIR__.'/lib/epcqr.lib.php'; require_once __DIR__.'/core/substitutions/functions_epcqr.lib.php'; $imageData = array(); if (!empty($qrPath) && file_exists($qrPath)) { $imageData['qrcode'] = $qrPath; } print '

Bilddaten gesammelt: '.count($imageData).' Bilder

'; if (!empty($imageData)) { print '
';
                print_r($imageData);
                print '
'; } } else { print '

✗ QR-Code-Datei nicht gefunden

'; print '

Lösung: Rechnung neu validieren (Draft → Validate)

'; } } else { print '

Rechnung nicht gefunden!

'; } } // Footer llxFooter(); $db->close();