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:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCarDocuments extends mfBaseModel
|
||||
{
|
||||
private $editor;
|
||||
private $creator;
|
||||
private $file;
|
||||
private $timerecordingCar;
|
||||
|
||||
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
if (!$this->id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
|
||||
if ($this->creator === null) {
|
||||
$this->creator = new User($this->create_by);
|
||||
if ($this->creator->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
|
||||
}
|
||||
}
|
||||
return $this->creator;
|
||||
}
|
||||
|
||||
if ($name == "editor") {
|
||||
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
|
||||
if ($this->editor === null) {
|
||||
$this->editor = new User($this->edit_by);
|
||||
if ($this->editor->id) {
|
||||
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
|
||||
}
|
||||
}
|
||||
return $this->editor;
|
||||
}
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name . "_id";
|
||||
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
|
||||
if (!$this->$name) {
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
}
|
||||
|
||||
if ($this->$name->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCarDocumentsController extends mfBaseController
|
||||
{
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->needlogin = true;
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
$this->me = $me;
|
||||
$this->layout()->set("me", $me);
|
||||
|
||||
if (!$me->is(["Admin"])) {
|
||||
$this->redirect("Dashboard");
|
||||
}
|
||||
}
|
||||
|
||||
protected function indexAction()
|
||||
{
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingCarDocuments/Index");
|
||||
$timerecordingcardocumentss = TimerecordingCarDocumentsModel::getAll();
|
||||
$this->layout()->set("timerecordingcardocumentss", $timerecordingcardocumentss);
|
||||
|
||||
}
|
||||
|
||||
protected function addAction()
|
||||
{
|
||||
$files=FileModel::getAll();
|
||||
$this->layout()->set("files", $files);
|
||||
$timerecordingCars=TimerecordingCarModel::getAll();
|
||||
$this->layout()->set("timerecordingCars", $timerecordingCars);
|
||||
|
||||
$this->layout()->setTemplate("TimerecordingCarDocuments/Form");
|
||||
|
||||
}
|
||||
|
||||
protected function editAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
|
||||
if (!is_numeric($id) || !$id) {
|
||||
$this->layout()->setFlash("bla nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
$timerecordingcardocumentss = new TimerecordingCarDocuments($id);
|
||||
if ($timerecordingcardocumentss->id != $id) {
|
||||
$this->layout()->setFlash("bla nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
$this->layout()->set("timerecordingcardocumentss", $timerecordingcardocumentss);
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function saveAction()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
//var_dump($r->get());exit;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$mode = "edit";
|
||||
$timerecordingcardocumentss = new TimerecordingCarDocuments($id);
|
||||
if (!$timerecordingcardocumentss->id) {
|
||||
$this->layout()->setFlash("gg nicht gefunden", "error");
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
} else {
|
||||
$mode = "add";
|
||||
}
|
||||
|
||||
$data = [];
|
||||
$data['file_id'] = trim($r->file_id);
|
||||
$data['file_size'] = trim($r->file_size);
|
||||
$data['timerecordingCar_id'] = trim($r->timerecordingCar_id);
|
||||
$data['name'] = trim($r->name);
|
||||
$data['description'] = trim($r->description);
|
||||
$data['sort'] = trim($r->sort);
|
||||
|
||||
|
||||
if (!$data['file_id']) {
|
||||
$data['file_id']=NULL;
|
||||
}
|
||||
if (!$data['file_size']) {
|
||||
$data['file_size']=NULL;
|
||||
}
|
||||
if (!$data['timerecordingCar_id']) {
|
||||
$data['timerecordingCar_id']=NULL;
|
||||
}
|
||||
if (!$data['name']) {
|
||||
$data['name']=NULL;
|
||||
}
|
||||
if (!$data['description']) {
|
||||
$data['description']=NULL;
|
||||
}
|
||||
if (!$data['sort']) {
|
||||
$data['sort']=NULL;
|
||||
}
|
||||
|
||||
|
||||
// var_dump($_FILES);
|
||||
// var_dump($upload);
|
||||
// exit;
|
||||
|
||||
|
||||
if ($mode == "edit") {
|
||||
$timerecordingcardocumentss->update($data);
|
||||
|
||||
} else {
|
||||
$timerecordingcardocumentss = TimerecordingCarDocumentsModel::create($data);
|
||||
}
|
||||
// var_dump($filestore);
|
||||
// exit;
|
||||
$id = $timerecordingcardocumentss->save();
|
||||
|
||||
if (!$id) {
|
||||
$this->layout()->setFlash("bla konnte nicht angelegt werden", "error");
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
if ($mode == "edit") {
|
||||
$this->layout()->setFlash("bla erfolgreich geändert", "success");
|
||||
} else if ($mode = "add") {
|
||||
$this->layout()->setFlash("bla erfolgreich angelegt", "success");
|
||||
}
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
|
||||
protected function deleteAction()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$timerecordingcardocumentss = new TimerecordingCarDocuments($id);
|
||||
if (!$timerecordingcardocumentss->id || $timerecordingcardocumentss->id != $id) {
|
||||
$this->layout()->setFlash("bla nicht gefunden.", "error");
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
$timerecordingcardocumentss->delete();
|
||||
$this->redirect("TimerecordingCarDocuments");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
class TimerecordingCarDocumentsModel
|
||||
{
|
||||
private $file_id;
|
||||
private $file_size;
|
||||
private $timerecordingCar_id;
|
||||
private $name;
|
||||
private $description;
|
||||
private $sort;
|
||||
|
||||
public static $mimetypes = [
|
||||
'application/pdf' => 'fa-file-pdf',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'fa-file-doc',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'fa-file-xls',
|
||||
'application/octet-stream' => 'fa-file-csv',
|
||||
'text/csv' => 'fa-file-csv',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'fa-file-ppt',
|
||||
'application/zip' => 'fa-file-zip',
|
||||
'application/x-zip-compressed' => 'fa-file-zip',
|
||||
'application/x-rar-compressed' => 'fa-file-archive',
|
||||
'application/x-7z-compressed' => 'fa-file-archive',
|
||||
'application/x-tar' => 'fa-file-archive',
|
||||
'application/x-gzip' => 'fa-file-archive',
|
||||
'application/x-bzip2' => 'fa-file-archive',
|
||||
'text/xml' => 'fa-file-xml',
|
||||
'application/xml' => 'fa-file-xml',
|
||||
'audio/mpeg' => 'fa-file-mp3',
|
||||
'image/png' => 'fa-file-png',
|
||||
'image/jpeg' => 'fa-file-jpg',
|
||||
];
|
||||
|
||||
public static function find($data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new TimerecordingCarDocuments();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getOne($id)
|
||||
{
|
||||
if (!is_numeric($id) || !$id) {
|
||||
throw new Exception("Invalid number", 400);
|
||||
}
|
||||
$item = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("TimerecordingCarDocuments", "*", "id=$id LIMIT 1");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TimerecordingCarDocuments($data);
|
||||
}
|
||||
return $item;
|
||||
}
|
||||
|
||||
public static function getAll()
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$res = $db->select("TimerecordingCarDocuments", "*", "1=1");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new TimerecordingCarDocuments($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getFirst()
|
||||
{
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("TimerecordingCarDocuments", "*", "$where ");
|
||||
if ($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new TimerecordingCarDocuments($data);
|
||||
if ($item->id) {
|
||||
return $item;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function search($filter)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("TimerecordingCarDocuments", "*", "$where");
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_object($res)) {
|
||||
$items[] = new TimerecordingCarDocuments($data);
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
private static function getSqlFilter($filter)
|
||||
{
|
||||
$where = "1=1 ";
|
||||
|
||||
//var_dump($filter);exit;
|
||||
if (array_key_exists("file_name", $filter)) {
|
||||
$file_name = $filter['file_name'];
|
||||
$where .= " AND file_name=$file_name";
|
||||
}
|
||||
|
||||
if (array_key_exists("timerecordingCar_id", $filter)) {
|
||||
$timerecordingCar_id = $filter['timerecordingCar_id'];
|
||||
$where .= " AND timerecordingCar_id=$timerecordingCar_id";
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user