64 lines
2.2 KiB
PHP
64 lines
2.2 KiB
PHP
<?php
|
|
// Debug-Script um Sections zu prüfen
|
|
require_once '../../main.inc.php';
|
|
require_once __DIR__.'/class/DocumentTypeHelper.class.php';
|
|
|
|
$order_id = 18; // Die Order-ID aus der Konsole
|
|
$docType = 'order';
|
|
|
|
$tables = DocumentTypeHelper::getTableNames($docType);
|
|
|
|
echo "<h2>Debug: Sections für Order ID $order_id</h2>";
|
|
|
|
// SQL-Abfrage 1: Alle Einträge für diese Order
|
|
$sql1 = "SELECT * FROM ".MAIN_DB_PREFIX."facture_lines_manager";
|
|
$sql1 .= " WHERE ".$tables['fk_parent']." = ".(int)$order_id;
|
|
$sql1 .= " ORDER BY line_order";
|
|
|
|
echo "<h3>SQL 1: Alle Einträge</h3>";
|
|
echo "<pre>".htmlspecialchars($sql1)."</pre>";
|
|
|
|
$resql1 = $db->query($sql1);
|
|
if ($resql1) {
|
|
echo "<table border='1'><tr><th>rowid</th><th>fk_commande</th><th>document_type</th><th>line_type</th><th>title</th><th>line_order</th></tr>";
|
|
while ($obj = $db->fetch_object($resql1)) {
|
|
echo "<tr>";
|
|
echo "<td>".$obj->rowid."</td>";
|
|
echo "<td>".$obj->fk_commande."</td>";
|
|
echo "<td>".$obj->document_type."</td>";
|
|
echo "<td>".$obj->line_type."</td>";
|
|
echo "<td>".$obj->title."</td>";
|
|
echo "<td>".$obj->line_order."</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
} else {
|
|
echo "<p style='color:red'>Fehler: ".$db->lasterror()."</p>";
|
|
}
|
|
|
|
// SQL-Abfrage 2: Nur Sections mit document_type
|
|
$sql2 = "SELECT * FROM ".MAIN_DB_PREFIX."facture_lines_manager";
|
|
$sql2 .= " WHERE ".$tables['fk_parent']." = ".(int)$order_id;
|
|
$sql2 .= " AND document_type = '".$db->escape($docType)."'";
|
|
$sql2 .= " AND line_type = 'section'";
|
|
$sql2 .= " ORDER BY line_order";
|
|
|
|
echo "<h3>SQL 2: Sections mit document_type = 'order'</h3>";
|
|
echo "<pre>".htmlspecialchars($sql2)."</pre>";
|
|
|
|
$resql2 = $db->query($sql2);
|
|
if ($resql2) {
|
|
$num = $db->num_rows($resql2);
|
|
echo "<p><strong>Anzahl gefunden: $num</strong></p>";
|
|
echo "<table border='1'><tr><th>rowid</th><th>title</th><th>line_order</th></tr>";
|
|
while ($obj = $db->fetch_object($resql2)) {
|
|
echo "<tr>";
|
|
echo "<td>".$obj->rowid."</td>";
|
|
echo "<td>".$obj->title."</td>";
|
|
echo "<td>".$obj->line_order."</td>";
|
|
echo "</tr>";
|
|
}
|
|
echo "</table>";
|
|
} else {
|
|
echo "<p style='color:red'>Fehler: ".$db->lasterror()."</p>";
|
|
}
|