Added support for Streamdeck Pedal and updated UI to better fit the Packed UI style
This commit is contained in:
53
pirp/tools/migrate_pdfs.php
Normal file
53
pirp/tools/migrate_pdfs.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Migrationsscript: Generiert PDFs für alle bestehenden Rechnungen
|
||||
*
|
||||
* ACHTUNG: Einmalig ausführen!
|
||||
* Bei bestehenden Rechnungen werden die AKTUELLEN Firmen-/Kundendaten verwendet.
|
||||
*
|
||||
* Ausführung: php tools/migrate_pdfs.php
|
||||
*/
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
echo "Nur CLI.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../src/config.php';
|
||||
require_once __DIR__ . '/../src/db.php';
|
||||
require_once __DIR__ . '/../src/pdf_functions.php';
|
||||
|
||||
echo "PDF-Migration gestartet...\n";
|
||||
|
||||
// Verzeichnis erstellen falls nicht vorhanden
|
||||
$uploadDir = __DIR__ . '/../public/uploads/invoices';
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0775, true);
|
||||
echo "Verzeichnis erstellt: $uploadDir\n";
|
||||
}
|
||||
|
||||
$pdo = get_db();
|
||||
$stmt = $pdo->query("SELECT id, invoice_number FROM invoices WHERE pdf_path IS NULL ORDER BY id");
|
||||
$invoices = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
echo "Gefunden: " . count($invoices) . " Rechnungen ohne archivierte PDF\n";
|
||||
|
||||
$success = 0;
|
||||
$failed = 0;
|
||||
|
||||
foreach ($invoices as $inv) {
|
||||
echo "Verarbeite {$inv['invoice_number']}... ";
|
||||
|
||||
$result = archive_invoice_pdf($inv['id']);
|
||||
|
||||
if ($result) {
|
||||
echo "OK -> $result\n";
|
||||
$success++;
|
||||
} else {
|
||||
echo "FEHLER\n";
|
||||
$failed++;
|
||||
}
|
||||
}
|
||||
|
||||
echo "\nMigration abgeschlossen.\n";
|
||||
echo "Erfolgreich: $success\n";
|
||||
echo "Fehlgeschlagen: $failed\n";
|
||||
Reference in New Issue
Block a user