Add spliceCompleted checkbox and update OAID handling in WorkorderMphBase
This commit is contained in:
@@ -16,6 +16,7 @@ class WorkorderMphModel extends TTCrudBaseModel
|
||||
public ?int $conduitToHuepLaid;
|
||||
public ?int $huepMounted;
|
||||
public ?int $dropCableAvailable;
|
||||
public ?int $spliceCompleted;
|
||||
public int $create;
|
||||
public int $createBy;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class WorkorderMphBaseController extends TTCrud
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$hausnummerId = $db->escape($workorder->hausnummerId);
|
||||
|
||||
$sql = "SELECT w.id, w.bezeichner, w.contact
|
||||
$sql = "SELECT w.id, w.bezeichner, w.contact, w.oaid, w.note
|
||||
FROM Wohneinheit w
|
||||
WHERE w.hausnummer_id = $hausnummerId
|
||||
ORDER BY w.bezeichner";
|
||||
@@ -161,12 +161,15 @@ class WorkorderMphBaseController extends TTCrud
|
||||
$response = [];
|
||||
foreach ($wohneinheiten as $we) {
|
||||
$record = $recordsMap[$we['id']] ?? null;
|
||||
// Prefer WorkorderMphWohneinheit note, fallback to addressdb note
|
||||
$note = $record ? $record->note : $we['note'];
|
||||
$response[] = [
|
||||
'wohneinheitId' => intval($we['id']),
|
||||
'bezeichner' => $we['bezeichner'],
|
||||
'contact' => $we['contact'],
|
||||
'oaid' => $we['oaid'],
|
||||
'status' => $record ? $record->status : 1,
|
||||
'note' => $record ? $record->note : null,
|
||||
'note' => $note,
|
||||
'recordId' => $record ? $record->id : null,
|
||||
];
|
||||
}
|
||||
@@ -215,6 +218,13 @@ class WorkorderMphBaseController extends TTCrud
|
||||
]);
|
||||
}
|
||||
|
||||
// Also save note to addressdb.Wohneinheit
|
||||
$db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$escapedNote = $note !== null ? "'" . $db->escape($note) . "'" : "NULL";
|
||||
$escapedWohneinheitId = $db->escape($wohneinheitId);
|
||||
$updateSql = "UPDATE Wohneinheit SET note = $escapedNote WHERE id = $escapedWohneinheitId";
|
||||
$db->query($updateSql);
|
||||
|
||||
// Add journal entry if status or note changed
|
||||
if ($oldStatus !== $status || $oldNote !== $note) {
|
||||
$changes = [];
|
||||
@@ -274,7 +284,7 @@ class WorkorderMphBaseController extends TTCrud
|
||||
if (!$workorder) self::sendError("Arbeitsauftrag nicht gefunden.");
|
||||
|
||||
$changes = [];
|
||||
$checkboxFields = ['easement', 'btb', 'fttxLocationSupplied', 'conduitToHuepLaid', 'huepMounted', 'dropCableAvailable'];
|
||||
$checkboxFields = ['easement', 'btb', 'fttxLocationSupplied', 'conduitToHuepLaid', 'huepMounted', 'dropCableAvailable', 'spliceCompleted'];
|
||||
|
||||
foreach ($checkboxFields as $field) {
|
||||
if (array_key_exists($field, $post)) {
|
||||
|
||||
Reference in New Issue
Block a user