Zeiterfassung Fahrzeugverwaltung neue Features:
* KM-Stand History * Journal * Neue Felder
This commit is contained in:
@@ -56,10 +56,14 @@ class TimerecordingCarController extends mfBaseController
|
||||
protected function detailAction()
|
||||
{
|
||||
$timerecordingcarid = $this->request->id;
|
||||
$timeRecordingCarMileageHistory = TimerecordingCarMileageHistoryModel::search(["timerecordingCar_id" => $timerecordingcarid]);
|
||||
$timerecordingCarJournal=TimerecordingCarJournalModel::search(["timerecordingCar_id" => $timerecordingcarid]);
|
||||
$mimetypes = TimerecordingCarDocumentsModel::$mimetypes;
|
||||
$timerecordingcarDokuments = TimerecordingCarDocumentsModel::search(["timerecordingCar_id" => $timerecordingcarid]);
|
||||
$this->layout()->set("mimetypes", $mimetypes);
|
||||
$this->layout()->set("timerecordingcarDokuments", $timerecordingcarDokuments);
|
||||
$this->layout()->set("timeRecordingCarMileageHistory", $timeRecordingCarMileageHistory);
|
||||
$this->layout()->set("timerecordingCarJournal", $timerecordingCarJournal);
|
||||
$this->layout()->setTemplate("TimerecordingCar/Detail");
|
||||
$timerecordingcar = TimerecordingCarModel::getOne($timerecordingcarid);
|
||||
$this->layout()->set("timerecordingcar", $timerecordingcar);
|
||||
@@ -127,6 +131,7 @@ class TimerecordingCarController extends mfBaseController
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$journal = trim($r->journal);
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
@@ -143,6 +148,12 @@ class TimerecordingCarController extends mfBaseController
|
||||
$data = [];
|
||||
$data['number_plate'] = trim($r->number_plate);
|
||||
$data['user_id'] = trim($r->user_id);
|
||||
$data['service_interval'] = trim($r->service_interval);
|
||||
$data['tires_at'] = trim($r->tires_at);
|
||||
$data['summer_tires'] = trim($r->summer_tires);
|
||||
$data['winter_tires'] = trim($r->winter_tires);
|
||||
$data['oil_type'] = trim($r->oil_type);
|
||||
$data['service_station'] = trim($r->service_station);
|
||||
$data['type'] = trim($r->type);
|
||||
$data['brand'] = trim($r->brand);
|
||||
$data['model'] = trim($r->model);
|
||||
@@ -157,6 +168,24 @@ class TimerecordingCarController extends mfBaseController
|
||||
if (!$data['user_id'] || $data['user_id'] == "-") {
|
||||
$data['user_id'] = null;
|
||||
}
|
||||
if (!$data['service_interval']) {
|
||||
$data['service_interval'] = null;
|
||||
}
|
||||
if (!$data['tires_at']) {
|
||||
$data['tires_at'] = null;
|
||||
}
|
||||
if (!$data['summer_tires']) {
|
||||
$data['summer_tires'] = null;
|
||||
}
|
||||
if (!$data['winter_tires']) {
|
||||
$data['winter_tires'] = null;
|
||||
}
|
||||
if (!$data['oil_type']) {
|
||||
$data['oil_type'] = null;
|
||||
}
|
||||
if (!$data['service_station']) {
|
||||
$data['service_station'] = null;
|
||||
}
|
||||
if (!$data['initial_approval']) {
|
||||
$data['initial_approval'] = null;
|
||||
}
|
||||
@@ -193,17 +222,51 @@ class TimerecordingCarController extends mfBaseController
|
||||
// var_dump($upload);
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mode == "edit") {
|
||||
if ($timerecordingcars->mileage_now != $data['mileage']) {
|
||||
$mileage_timestamp = $r->mileage_timestamp;
|
||||
if (!$mileage_timestamp) {
|
||||
$data['mileage_timestamp'] = time();
|
||||
} else {
|
||||
$data['mileage_timestamp'] = strtotime($mileage_timestamp);
|
||||
}
|
||||
$datamileageHistory = [];
|
||||
$datamileageHistory['timerecordingCar_id'] = $timerecordingcars->id;
|
||||
$datamileageHistory['mileage'] = $timerecordingcars->mileage_now;
|
||||
if ($timerecordingcars->mileage_timestamp) {
|
||||
$datamileageHistory['mileage_timestamp'] = $timerecordingcars->mileage_timestamp;
|
||||
} else {
|
||||
$datamileageHistory['mileage_timestamp'] = $timerecordingcars->edit;
|
||||
}
|
||||
$timerecordingcarsMilageHistory = TimerecordingCarMileageHistoryModel::create($datamileageHistory);
|
||||
$timerecordingcarsMilageHistory->save();
|
||||
}
|
||||
$timerecordingcars->update($data);
|
||||
|
||||
} else {
|
||||
if ($data['mileage'] != null) {
|
||||
$data['mileage_timestamp'] = time();
|
||||
}
|
||||
$timerecordingcars = TimerecordingCarModel::create($data);
|
||||
}
|
||||
// var_dump($filestore);
|
||||
// exit;
|
||||
$id = $timerecordingcars->save();
|
||||
|
||||
if ($journal) {
|
||||
$journal_timestamp = $r->journal_timestamp;
|
||||
$dataJournal = [];
|
||||
$dataJournal['timerecordingCar_id'] = $id;
|
||||
$dataJournal['journal'] = $journal;
|
||||
if ($journal_timestamp) {
|
||||
$dataJournal['timestamp'] = strtotime($journal_timestamp);
|
||||
} else {
|
||||
$dataJournal['timestamp'] = time();
|
||||
}
|
||||
$timerecordingcarJournal = TimerecordingCarJournalModel::create($dataJournal);
|
||||
$timerecordingcarJournal->save();
|
||||
}
|
||||
|
||||
$returnUrl = "TimerecordingCar";
|
||||
$returnAction = "Index";
|
||||
$returnVariables = array();
|
||||
@@ -216,8 +279,7 @@ class TimerecordingCarController extends mfBaseController
|
||||
$returnVariables['hash'] = $this->request->hash;
|
||||
}
|
||||
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
if ($this->request->hash) {
|
||||
$returnAnker = $this->request->hash;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user