added technical data to xinon workorder and workordermph now has a unassign button
This commit is contained in:
@@ -375,4 +375,38 @@ class WorkorderMphAdminController extends WorkorderMphBaseController
|
||||
|
||||
self::returnJson(['success' => true, 'message' => 'Arbeitsauftrag wurde storniert.']);
|
||||
}
|
||||
|
||||
protected function unassignWorkorderAction()
|
||||
{
|
||||
if (empty($this->postData['workorderId'])) self::sendError("Arbeitsauftrags-ID fehlt.");
|
||||
|
||||
$workorder = WorkorderMphModel::get($this->postData['workorderId']);
|
||||
if (!$workorder) self::sendError("Arbeitsauftrag nicht gefunden.");
|
||||
|
||||
if ($workorder->status === 'new') self::sendError("Arbeitsauftrag ist nicht zugewiesen.");
|
||||
if (in_array($workorder->status, ['completed', 'cancelled'])) self::sendError("Arbeitsauftrag kann nicht mehr geändert werden.");
|
||||
|
||||
$oldStatus = $workorder->status;
|
||||
$oldCompany = $workorder->companyId ? WorkorderCompanyModel::get($workorder->companyId) : null;
|
||||
$oldCompanyName = $oldCompany ? $oldCompany->name : 'Unbekannt';
|
||||
|
||||
$workorder->status = 'new';
|
||||
$workorder->companyId = null;
|
||||
$workorder->assignmentDate = null;
|
||||
$workorder->deadlineDate = null;
|
||||
$workorder->appointmentDate = null;
|
||||
WorkorderMphModel::update((array)$workorder);
|
||||
|
||||
$reason = !empty($this->postData['reason']) ? " Grund: " . $this->postData['reason'] : '';
|
||||
|
||||
WorkorderMphJournalModel::create([
|
||||
'workorderMphId' => $workorder->id,
|
||||
'text' => "Zuweisung aufgehoben (vorher: $oldCompanyName).$reason",
|
||||
'statusChange' => $this->getStatusText($oldStatus) . " -> " . $this->getStatusText('new'),
|
||||
'create' => time(),
|
||||
'createBy' => $this->user->id,
|
||||
]);
|
||||
|
||||
self::returnJson(['success' => true, 'message' => 'Zuweisung wurde aufgehoben.']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user