Mobile Integration,Pop Multiple Networks,DataTables responsible update,Migrations

Mobile Integration:
* in footer.php js eingefügt damit das mobile Menu funktioniert
* in menu.php bzw. app.css neue Klasse eingefügt mobile-hide um in der mobilen Version Menupünkte zu verstecken

Pop Multiple Networks
* Pops können nun mehrere Netzgebiete haben
* Netzgebiete und Pop ansicht angepasst
* (Script muss ausgeführt werden um die PopNetwork Table vom Bestand zu befüllen)

DataTables responsible update
* Datatables update und responsible addon
* Diverse Anpassungen für Responsible in:
  - Pops, Geräte Hersteller, Geräte Typen, Devices, Benutzer

Anpassungen auf neu getProperty

Migrations
* PopNetwork
* Poprackmodulepatch
This commit is contained in:
Spitzer Daniel
2024-01-09 16:25:26 +01:00
parent 2f2c922d81
commit 828caa35c9
16 changed files with 1979 additions and 6 deletions
@@ -0,0 +1,61 @@
<?php
class Timerecording extends mfBaseModel
{
private $editor;
private $creator;
private $user;
private $timerecordingCategory;
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 TimerecordingController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->is(["employee"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("Timerecording/Index");
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$timerecordings = TimerecordingModel::search(['user_id' => $this->me->id]);
$this->layout()->set("timerecordings", $timerecordings);
}
protected function addAction()
{
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$this->layout()->setTemplate("Timerecording/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Buchung nicht gefunden", "error");
$this->redirect("Timerecording");
}
$timerecordings = new Timerecording($id);
if ($timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden", "error");
$this->redirect("Timerecording");
}
$this->layout()->set("timerecordings", $timerecordings);
return $this->addAction();
}
protected function saveAction()
{
$r = $this->request;
$id = $r->id;
$enddate = $r->enddate;
if (!$enddate && $r->start && $r->end) {
$starttime = strtotime($r->date . " " . $r->start . ":00");
$endtime = strtotime($r->date . " " . $r->end . ":00");
} elseif ($enddate) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = strtotime($enddate . " 23:59:00");
} else if (!$enddate && !$r->start && !$r->end) {
$starttime = strtotime($r->date . " 00:00:00");
$endtime = NULL;
}
if (is_numeric($id) && $id > 0) {
$mode = "edit";
$timerecordings = new Timerecording($id);
if (!$timerecordings->id) {
$this->layout()->setFlash("Buchungen nicht gefunden", "error");
$this->redirect("Timerecording");
}
} else {
$mode = "add";
}
$data = [];
$data['user_id'] = $this->me->id;
$data['start'] = $starttime;
$data['end'] = $endtime;
$data['timerecordingCategory_id'] = trim($r->timerecordingCategory_id);
$data['commend'] = trim($r->commend);
if (!$data['user_id']) {
$this->layout()->setFlash("Benutzer darf nicht leer sein", "error");
$this->redirect("Timerecording");
}
if ($data['start'] < 1577833200) {
$this->layout()->setFlash("Ungültige Startzeit", "error");
$this->redirect("Timerecording");
}
if ($data['end'] && $data['end'] < 1577833200) {
$this->layout()->setFlash("Ungültige Endzeit", "error");
$this->redirect("Timerecording");
}
if (!$data['timerecordingCategory_id']) {
$data['timerecordingCategory_id'] = NULL;
}
if (!$data['commend']) {
$data['commend'] = NULL;
}
if ($mode == "edit") {
$timerecordings->update($data);
} else {
$timerecordings = TimerecordingModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordings->save();
if (!$id) {
$this->layout()->setFlash("Buchung konnte nicht angelegt werden", "error");
$this->redirect("Timerecording");
}
if ($mode == "edit") {
$this->layout()->setFlash("Buchung erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Buchung erfolgreich angelegt", "success");
}
$this->redirect("Timerecording");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordings = new Timerecording($id);
if (!$timerecordings->id || $timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
$this->redirect("Timerecording");
}
$timerecordings->delete();
$this->redirect("Timerecording");
}
}
@@ -0,0 +1,148 @@
<?php
class TimerecordingModel
{
private $user_id;
private $start;
private $end;
private $timerecordingCategory_id;
private $commend;
private $approved;
private $completed;
public static function find($data)
{
}
public static function create(array $data)
{
$model = new Timerecording();
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("Timerecording", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Timerecording($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("Timerecording", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Timerecording($data);
}
}
return $items;
}
public static function getAllPermits()
{
$items = [];
$db = FronkDB::singleton();
$sql = "SELECT Timerecording.* FROM `Timerecording`
INNER JOIN `TimerecordingCategory` ON (`Timerecording`.`timerecordingCategory_id` = `TimerecordingCategory`.`id`)
WHERE `TimerecordingCategory`.`approval`='1'";
$res = $db->query($sql);
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Timerecording($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("Timerecording", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Timerecording($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("Timerecording", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new Timerecording($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
if (array_key_exists("user_id", $filter)) {
$userid = $filter['user_id'];
if (is_numeric($userid)) {
$where .= " AND user_id=$userid";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}
@@ -0,0 +1,41 @@
<?php
class TimerecordingCategory extends mfBaseModel
{
private $editor;
private $creator;
public function getProperty($name)
{
if ($this->$name == null) {
if (!$this->id) {
return null;
}
if ($name == "creator") {
$this->creator = new User($this->create_by);
return $this->creator;
}
if ($name == "editor") {
$this->editor = new User($this->edit_by);
return $this->editor;
}
$classname = ucfirst($name);
$idfield = $name . "_id";
$this->$name = new $classname($this->$idfield);
if ($this->$name->id) {
return $this->$name;
} else {
return null;
}
}
return $this->$name;
}
}
@@ -0,0 +1,141 @@
<?php
class TimerecordingCategoryController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->can(["Fibu"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("TimerecordingCategories/Index");
$timerecordingcategoriesapproval = TimerecordingCategoryModel::$approval_definition;
$timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition;
$timerecordingcategoriesrequire_comment = TimerecordingCategoryModel::$require_comment_definition;
$timerecordingcategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingcategoriesrequire_comment", $timerecordingcategoriesrequire_comment);
$this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday);
$this->layout()->set("timerecordingcategoriesapproval", $timerecordingcategoriesapproval);
$this->layout()->set("timerecordingcategoriess", $timerecordingcategoriess);
}
protected function addAction()
{
$timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition;
$this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday);
$this->layout()->setTemplate("TimerecordingCategories/Form");
}
protected function editAction()
{
$id = $this->request->id;
if (!is_numeric($id) || !$id) {
$this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden", "error");
$this->redirect("TimerecordingCategory");
}
$timerecordingcategoriess = new TimerecordingCategory($id);
if ($timerecordingcategoriess->id != $id) {
$this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden", "error");
$this->redirect("TimerecordingCategory");
}
$timerecordingcategorieshourday = TimerecordingCategoryModel::$hourday_definition;
$this->layout()->set("timerecordingcategorieshourday", $timerecordingcategorieshourday);
$this->layout()->set("timerecordingcategoriess", $timerecordingcategoriess);
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";
$timerecordingcategoriess = new TimerecordingCategory($id);
if (!$timerecordingcategoriess->id) {
$this->layout()->setFlash("Zeiterfassung Kategorien nicht gefunden", "error");
$this->redirect("TimerecordingCategory");
}
} else {
$mode = "add";
}
$data = [];
$data['name'] = trim($r->name);
$data['short'] = trim($r->short);
$data['hourday'] = trim($r->hourday);
$data['approval'] = trim($r->approval);
$data['require_comment'] = trim($r->require_comment);
if (!$data['name']) {
$data['name'] = NULL;
}
if (!$data['short']) {
$data['short'] = NULL;
}
if (!$data['approval']) {
$data['approval'] = 0;
}
if (!$data['require_comment']) {
$data['require_comment'] = 0;
}
// var_dump($_FILES);
// var_dump($upload);
// exit;
if ($mode == "edit") {
$timerecordingcategoriess->update($data);
} else {
$timerecordingcategoriess = TimerecordingCategoryModel::create($data);
}
// var_dump($filestore);
// exit;
$id = $timerecordingcategoriess->save();
if (!$id) {
$this->layout()->setFlash("Zeiterfassung Kategorie konnte nicht angelegt werden", "error");
$this->redirect("TimerecordingCategory");
}
if ($mode == "edit") {
$this->layout()->setFlash("Zeiterfassung Kategorie erfolgreich geändert", "success");
} else if ($mode = "add") {
$this->layout()->setFlash("Zeiterfassung Kategorie erfolgreich angelegt", "success");
}
$this->redirect("TimerecordingCategory");
}
protected function deleteAction()
{
$id = $this->request->id;
$timerecordingcategoriess = new TimerecordingCategory($id);
if (!$timerecordingcategoriess->id || $timerecordingcategoriess->id != $id) {
$this->layout()->setFlash("Zeiterfassung Kategorie nicht gefunden.", "error");
$this->redirect("TimerecordingCategory");
}
$timerecordingcategoriess->delete();
$this->redirect("TimerecordingCategory");
}
}
@@ -0,0 +1,132 @@
<?php
class TimerecordingCategoryModel
{
private $name;
private $short;
private $hourday;
private $approval;
private $require_comment;
public static $hourday_definition = array(1 => "Uhrzeit (von/bis)", 2 => "Tage (von/bis)", 3 => "Startdatum", 4 => "Enddatum");
public static $approval_definition = array(0 => "Nein", 1 => "Ja");
public static $require_comment_definition = array(0 => "Nein", 1 => "Ja");
public static function find($data)
{
}
public static function create(array $data)
{
$model = new TimerecordingCategory();
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("timerecordingCategory", "*", "id=$id LIMIT 1");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCategory($data);
}
return $item;
}
public static function getAll()
{
$items = [];
$db = FronkDB::singleton();
$res = $db->select("TimerecordingCategory", "*", "1=1");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCategory($data);
}
}
return $items;
}
public static function getFirst()
{
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$res = $db->select("TimerecordingCategory", "*", "$where ");
if ($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new TimerecordingCategory($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("TimerecordingCategory", "*", "$where");
if ($db->num_rows($res)) {
while ($data = $db->fetch_object($res)) {
$items[] = new TimerecordingCategory($data);
}
}
return $items;
}
private static function getSqlFilter($filter)
{
$where = "1=1 ";
//var_dump($filter);exit;
if (array_key_exists("network_id", $filter)) {
$networkid = $filter['network_id'];
if (is_numeric($networkid)) {
$where .= " AND network_id=$networkid";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}
@@ -0,0 +1,62 @@
<?php
class TimerecordingPermitController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->can(["Fibu"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("TimerecordingPermit/Index");
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$timerecordings = TimerecordingModel::getAllPermits();
$this->layout()->set("timerecordings", $timerecordings);
}
protected function addAction()
{
}
protected function editAction()
{
}
protected function saveAction()
{
}
protected function approveAction()
{
$id = $this->request->id;
$timerecordings = new Timerecording($id);
if (!$timerecordings->id || $timerecordings->id != $id) {
$this->layout()->setFlash("Buchung nicht gefunden.", "error");
$this->redirect("TimerecordingPermit");
}
$data = [];
$data['approved'] = 1;
$timerecordings->update($data);
$timerecordings->save();
$this->redirect("TimerecordingPermit");
}
}
@@ -0,0 +1,51 @@
<?php
class TimerecordingReportController extends mfBaseController
{
protected function init()
{
$this->needlogin = true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me", $me);
if (!$me->can(["Fibu"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction()
{
$this->layout()->setTemplate("TimerecordingReport/Index");
$timerecordingCategoriess = TimerecordingCategoryModel::getAll();
$this->layout()->set("timerecordingCategoriess", $timerecordingCategoriess);
$timerecordings = TimerecordingModel::getAll();
$this->layout()->set("timerecordings", $timerecordings);
}
protected function addAction()
{
}
protected function editAction()
{
}
protected function saveAction()
{
}
protected function deleteAction()
{
}
}