Zeiterfassung neues Feature:
Features für Project 7832: * Das Pickerldatum Zusatzfeld * Auftrennen PKW und Anhänger * Dokumente Upload * Standardsortierung * Ausgeschieden Flag mit Datum * zusätzliche migration
This commit is contained in:
@@ -16,6 +16,34 @@ class TimerecordingCarController extends mfBaseController
|
||||
}
|
||||
}
|
||||
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
|
||||
|
||||
switch ($do) {
|
||||
case "uploadDocuments":
|
||||
|
||||
$return = $this->uploadDocument();
|
||||
break;
|
||||
case "getDocuments":
|
||||
$return = $this->getDocuments();
|
||||
break;
|
||||
case "deleteDocument":
|
||||
$return = $this->deleteDocument();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
if (!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
@@ -28,6 +56,10 @@ class TimerecordingCarController extends mfBaseController
|
||||
protected function detailAction()
|
||||
{
|
||||
$timerecordingcarid = $this->request->id;
|
||||
$mimetypes = TimerecordingCarDocumentsModel::$mimetypes;
|
||||
$timerecordingcarDokuments = TimerecordingCarDocumentsModel::search(["timerecordingCar_id" => $timerecordingcarid]);
|
||||
$this->layout()->set("mimetypes", $mimetypes);
|
||||
$this->layout()->set("timerecordingcarDokuments", $timerecordingcarDokuments);
|
||||
$this->layout()->setTemplate("TimerecordingCar/Detail");
|
||||
$timerecordingcar = TimerecordingCarModel::getOne($timerecordingcarid);
|
||||
$this->layout()->set("timerecordingcar", $timerecordingcar);
|
||||
@@ -54,16 +86,44 @@ class TimerecordingCarController extends mfBaseController
|
||||
}
|
||||
|
||||
$timerecordingcars = new TimerecordingCar($id);
|
||||
$mimetypes = TimerecordingCarDocumentsModel::$mimetypes;
|
||||
$timerecordingcarDokuments = TimerecordingCarDocumentsModel::search(["timerecordingCar_id" => $id]);
|
||||
if ($timerecordingcars->id != $id) {
|
||||
$this->layout()->setFlash("Auto nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCar");
|
||||
}
|
||||
|
||||
|
||||
$this->layout()->set("mimetypes", $mimetypes);
|
||||
$this->layout()->set("timerecordingcarDokuments", $timerecordingcarDokuments);
|
||||
$this->layout()->set("timerecordingcars", $timerecordingcars);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function retireAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$retired_date = $r->retired_date;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$timerecordingcars = new TimerecordingCar($id);
|
||||
if (!$timerecordingcars->id) {
|
||||
$this->layout()->setFlash("Fahrzeug nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCar");
|
||||
}
|
||||
} else {
|
||||
$this->layout()->setFlash("Fahrzeug nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCar");
|
||||
}
|
||||
$data = [];
|
||||
$data['retired'] = 1;
|
||||
$data['retired_date'] = strtotime($retired_date);
|
||||
$data['edit_by'] = $this->me->id;
|
||||
$timerecordingcars->update($data);
|
||||
$timerecordingcars->save();
|
||||
$this->layout()->setFlash("Fahrzeug erfolgreich ausgeschieden", "success");
|
||||
$this->redirect("TimerecordingCar");
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
@@ -83,12 +143,15 @@ class TimerecordingCarController extends mfBaseController
|
||||
$data = [];
|
||||
$data['number_plate'] = trim($r->number_plate);
|
||||
$data['user_id'] = trim($r->user_id);
|
||||
$data['type'] = trim($r->type);
|
||||
$data['brand'] = trim($r->brand);
|
||||
$data['model'] = trim($r->model);
|
||||
$data['mileage'] = trim($r->mileage);
|
||||
$data['initial_approval'] = strtotime($r->initial_approval);
|
||||
$data['timerecording'] = $r->timerecording;
|
||||
$data['first_approval'] = trim($r->first_approval);
|
||||
$data['override_approval'] = strtotime(trim($r->override_approval));
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
|
||||
if (!$data['user_id'] || $data['user_id'] == "-") {
|
||||
@@ -97,6 +160,9 @@ class TimerecordingCarController extends mfBaseController
|
||||
if (!$data['initial_approval']) {
|
||||
$data['initial_approval'] = null;
|
||||
}
|
||||
if (!$data['override_approval']) {
|
||||
$data['override_approval'] = null;
|
||||
}
|
||||
|
||||
if (!$data['timerecording']) {
|
||||
$data['timerecording'] = 0;
|
||||
@@ -176,4 +242,64 @@ class TimerecordingCarController extends mfBaseController
|
||||
$this->redirect("TimerecordingCar");
|
||||
}
|
||||
|
||||
protected function uploadDocument()
|
||||
{
|
||||
$r = $this->request;
|
||||
if (array_key_exists("timeRecordingCar", $_FILES) && !$_FILES['timeRecordingCar']['error']) {
|
||||
$upload_error = false;
|
||||
$upload = new mfUpload("timeRecordingCar");
|
||||
$upload->setSavepath(MFUPLOAD_FILE_SAVE_PATH . "/timeRecordingCar");
|
||||
if (!$upload->getSize()) {
|
||||
die();
|
||||
}
|
||||
$upload->save();
|
||||
$file_data = [];
|
||||
$file_data['name'] = $upload->getOriginalFilename();
|
||||
$file_data['filename'] = ($r->file_filename) ? $r->file_filename : $upload->getOriginalFilename();
|
||||
$file_data['subfolder'] = "timeRecordingCar";
|
||||
$file_data['store_filename'] = $upload->getFilename();
|
||||
$file_data['orig_filename'] = $upload->getOriginalFilename();
|
||||
|
||||
$file = FileModel::create($file_data);
|
||||
$file_id = $file->save();
|
||||
if (!$file_id) {
|
||||
die();
|
||||
} else {
|
||||
$data = [];
|
||||
$data['file_id'] = $file_id;
|
||||
$data['file_size'] = $upload->getSize();
|
||||
$data['timerecordingCar_id'] = $r->timerecordingCar_id;
|
||||
$data['name'] = $upload->getOriginalFilename();
|
||||
$timerecordingcardocumentss = TimerecordingCarDocumentsModel::create($data);
|
||||
$id = $timerecordingcardocumentss->save();
|
||||
}
|
||||
$result['success'] = true;
|
||||
$result['data']['file_id'] = $file_id;
|
||||
$result['data']['id'] = $id;
|
||||
} else {
|
||||
echo "error";
|
||||
}
|
||||
echo json_encode($result);
|
||||
die();
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected function getDocuments()
|
||||
{
|
||||
$r = $this->request;
|
||||
$file_name = $r->file_name;
|
||||
$timerecordingCarDokument = TimerecordingCarDocumentsModel::search(["file_name" => $file_name]);
|
||||
return $timerecordingCarDokument->file_id;
|
||||
}
|
||||
|
||||
protected function deleteDocument()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$timerecordingCarDokument = new TimerecordingCarDocuments($id);
|
||||
$timerecordingCarDokument->file->delete();
|
||||
$timerecordingCarDokument->delete();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user