added new features
This commit is contained in:
@@ -26,6 +26,25 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
['key' => 'deadlineDate', 'text' => 'Deadline', 'modal' => false, 'table' => ['filter' => 'date']],
|
||||
];
|
||||
|
||||
private function getStatusText(string $statusKey): string {
|
||||
$statusColumn = null;
|
||||
foreach ($this->columns as $column) {
|
||||
if ($column['key'] === 'status') {
|
||||
$statusColumn = $column;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($statusColumn) {
|
||||
foreach ($statusColumn['table']['filterOptions'] as $option) {
|
||||
if ($option['value'] === $statusKey) {
|
||||
return $option['text'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ucfirst(str_replace('_', ' ', $statusKey)); // Fallback
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
$campaigns = Helper::getPreorderCampaignFromUser($this->user, true);
|
||||
@@ -105,20 +124,52 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
protected function getDocumentationAction() {
|
||||
if(empty($this->request->workorderId)) self::sendError("Workorder ID missing.");
|
||||
|
||||
$docs = RMLWorkorderDocumentationModel::getAll(['workorderId' => $this->request->workorderId], null, 0, ['key' => 'create', 'order' => 'DESC']);
|
||||
$docs = RMLWorkorderDocumentationModel::getAll(['workorderId' => $this->request->workorderId], null, 0, ['key' => 'create', 'order' => 'ASC']);
|
||||
$journals = RMLWorkorderJournalModel::getAll(['workorderId' => $this->request->workorderId], null, 0, ['key' => 'create', 'order' => 'DESC']);
|
||||
$users = UserModel::search();
|
||||
|
||||
$translationMap = [
|
||||
'photo_hup_mounted' => 'Foto_montierter_HÜP',
|
||||
'photo_hup_open' => 'Foto_offener_HÜP',
|
||||
'photo_splice_cassette_hup' => 'Foto_Spleißkassette_HÜP',
|
||||
'photo_splice_cassette_fcp' => 'Foto_Spleißkassette_FCP',
|
||||
'photo_hup_closed_stickers' => 'Foto_geschlossener_HÜP_mit_Aufklebern',
|
||||
'photo_fcp_labeled' => 'Foto_FCP_beschriftet',
|
||||
'photo_patch_position_osp' => 'Foto_Patch-Position_OSP-Seite',
|
||||
'photo_patch_position_anb' => 'Foto_Patch-Position_ANB-Seite',
|
||||
'measurement_protocol_otdr' => 'ODTR_Messung',
|
||||
'other' => 'Sonstiges_Dokument'
|
||||
];
|
||||
|
||||
$responseDocs = [];
|
||||
$typeCounts = [];
|
||||
|
||||
foreach($docs as $doc) {
|
||||
$file = new File($doc->fileId);
|
||||
$doc->fileName = $file->orig_filename ?? $file->filename;
|
||||
$doc->userName = UserModel::getOne($doc->createBy)->name ?? 'Unbekannt';
|
||||
$doc->mimetype = $file->mimetype ?? 'application/octet-stream';
|
||||
$documentTypeKey = $doc->documentType;
|
||||
|
||||
$typeCounts[$documentTypeKey] = ($typeCounts[$documentTypeKey] ?? 0) + 1;
|
||||
|
||||
$originalFilename = $file->orig_filename ?? $file->filename;
|
||||
$extension = pathinfo($originalFilename, PATHINFO_EXTENSION);
|
||||
$translatedType = $translationMap[$documentTypeKey] ?? $documentTypeKey;
|
||||
$newFilename = "{$translatedType}_{$typeCounts[$documentTypeKey]}." . strtolower($extension);
|
||||
|
||||
$responseDocs[] = [
|
||||
'id' => $doc->id,
|
||||
'fileId' => $doc->fileId,
|
||||
'fileName' => $newFilename,
|
||||
'description' => $doc->description,
|
||||
'documentType' => $documentTypeKey,
|
||||
'userName' => UserModel::getOne($doc->createBy)->name ?? 'Unbekannt',
|
||||
'mimetype' => $file->mimetype ?? 'application/octet-stream',
|
||||
];
|
||||
}
|
||||
|
||||
foreach($journals as $journal) {
|
||||
$journal->createByName = UserModel::getOne($journal->createBy)->name ?? 'Unbekannt';
|
||||
}
|
||||
self::returnJson(['docs' => $docs, 'journals' => $journals]);
|
||||
|
||||
self::returnJson(['docs' => $responseDocs, 'journals' => $journals]);
|
||||
}
|
||||
|
||||
private function assignSingleWorkorder($workorderId, $companyId, $deadline, $userId) {
|
||||
@@ -200,9 +251,9 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
|
||||
RMLWorkorderJournalModel::create([
|
||||
'workorderId' => $workorder->id,
|
||||
'text' => $post['text'],
|
||||
'text' => "Korrektur angefordert. Grund: " . $post['text'],
|
||||
'fileIds' => !empty($post['fileIds']) ? json_encode($post['fileIds']) : null,
|
||||
'statusChange' => "$oldStatus -> correction_requested",
|
||||
'statusChange' => $this->getStatusText($oldStatus) . " -> " . $this->getStatusText('correction_requested'),
|
||||
'create' => time(),
|
||||
'createBy' => $this->user->id,
|
||||
]);
|
||||
@@ -283,7 +334,7 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
RMLWorkorderJournalModel::create([
|
||||
'workorderId' => $workorder->id,
|
||||
'text' => 'Dokumentation wurde akzeptiert und der Auftrag abgeschlossen.',
|
||||
'statusChange' => "$oldStatus -> completed",
|
||||
'statusChange' => $this->getStatusText($oldStatus) . " -> " . $this->getStatusText('completed'),
|
||||
'create' => time(),
|
||||
'createBy' => $this->user->id,
|
||||
]);
|
||||
@@ -292,11 +343,6 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
}
|
||||
|
||||
protected function setToProblemSolvedAction() {
|
||||
// const response = await axios.post(`${window.TT_CONFIG.BASE_PATH}/RMLWorkorderAdmin/setToProblemSolved`, {
|
||||
// workorderId: row.id,
|
||||
// text: text
|
||||
// });
|
||||
|
||||
$post = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
if (empty($post['workorderId']) || empty($post['text'])) {
|
||||
@@ -317,13 +363,10 @@ class RMLWorkorderAdminController extends TTCrud
|
||||
$workorder->status = 'problem_solved';
|
||||
RMLWorkorderModel::update((array)$workorder);
|
||||
|
||||
$oldStatusText = $oldStatus === 'intervention_required' ? 'Eingriff benötigt' : $oldStatus;
|
||||
$problem_solved = 'Problem gelöst';
|
||||
|
||||
RMLWorkorderJournalModel::create([
|
||||
'workorderId' => $workorder->id,
|
||||
'text' => $post['text'],
|
||||
'statusChange' => "$oldStatusText -> $problem_solved",
|
||||
'text' => "Problem behoben: " . $post['text'],
|
||||
'statusChange' => $this->getStatusText($oldStatus) . " -> " . $this->getStatusText('problem_solved'),
|
||||
'create' => time(),
|
||||
'createBy' => $this->user->id,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user