added dect option for rooms
This commit is contained in:
parent
88c727bf8e
commit
4d6da1894a
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Engelsystem\Migrations;
|
||||
|
||||
use Engelsystem\Database\Migration\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class AddDectToRooms extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$this->schema->table(
|
||||
'rooms',
|
||||
function (Blueprint $table) {
|
||||
$table->text('dect')->nullable()->after('description');
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->table(
|
||||
'rooms',
|
||||
function (Blueprint $table) {
|
||||
$table->dropColumn('dect');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
|
@ -72,16 +72,18 @@ function Room_delete(Room $room)
|
|||
*
|
||||
* @return null|int
|
||||
*/
|
||||
function Room_create(string $name, string $map_url = null, string $description = null)
|
||||
function Room_create(string $name, string $map_url = null, string $description = null, string $dect = null)
|
||||
{
|
||||
$room = new Room();
|
||||
$room->name = $name;
|
||||
$room->description = $description;
|
||||
$room->map_url = $map_url;
|
||||
$room->dect = $dect;
|
||||
$room->save();
|
||||
|
||||
engelsystem_log(
|
||||
'Room created: ' . $name
|
||||
. ', dect: ' . $dect
|
||||
. ', map_url: ' . $map_url
|
||||
. ', description: ' . $description
|
||||
);
|
||||
|
@ -97,16 +99,23 @@ function Room_create(string $name, string $map_url = null, string $description =
|
|||
* @param string|null $map_url URL to a map tha can be displayed in an iframe
|
||||
* @param string|null $description Markdown description
|
||||
*/
|
||||
function Room_update(int $room_id, string $name, string $map_url = null, string $description = null)
|
||||
{
|
||||
function Room_update(
|
||||
int $room_id,
|
||||
string $name,
|
||||
string $map_url = null,
|
||||
string $description = null,
|
||||
string $dect = null
|
||||
) {
|
||||
$room = Room::find($room_id);
|
||||
$room->name = $name;
|
||||
$room->description = $description ?: null;
|
||||
$room->map_url = $map_url ?: null;
|
||||
$room->dect = $dect ?: null;
|
||||
$room->save();
|
||||
|
||||
engelsystem_log(
|
||||
'Room updated: ' . $name .
|
||||
', dect: ' . $dect .
|
||||
', map_url: ' . $map_url .
|
||||
', description: ' . $description
|
||||
);
|
||||
|
|
|
@ -24,6 +24,7 @@ function admin_rooms()
|
|||
foreach ($rooms_source as $room) {
|
||||
$rooms[] = [
|
||||
'name' => Room_name_render($room),
|
||||
'dect' => icon_bool($room->dect),
|
||||
'map_url' => icon_bool($room->map_url),
|
||||
'actions' => table_buttons([
|
||||
button(
|
||||
|
@ -46,6 +47,7 @@ function admin_rooms()
|
|||
$name = '';
|
||||
$map_url = null;
|
||||
$description = null;
|
||||
$dect = null;
|
||||
$room_id = 0;
|
||||
|
||||
$angeltypes_source = AngelTypes();
|
||||
|
@ -66,6 +68,7 @@ function admin_rooms()
|
|||
$name = $room->name;
|
||||
$map_url = $room->map_url;
|
||||
$description = $room->description;
|
||||
$dect = $room->dect;
|
||||
|
||||
$needed_angeltypes = NeededAngelTypes_by_room($room_id);
|
||||
foreach ($needed_angeltypes as $needed_angeltype) {
|
||||
|
@ -97,6 +100,9 @@ function admin_rooms()
|
|||
if ($request->has('description')) {
|
||||
$description = strip_request_item_nl('description');
|
||||
}
|
||||
if ($request->has('dect')) {
|
||||
$dect = strip_request_item_nl('dect');
|
||||
}
|
||||
|
||||
foreach ($angeltypes as $angeltype_id => $angeltype) {
|
||||
$angeltypes_count[$angeltype_id] = 0;
|
||||
|
@ -118,9 +124,9 @@ function admin_rooms()
|
|||
|
||||
if ($valid) {
|
||||
if (empty($room_id)) {
|
||||
$room_id = Room_create($name, $map_url, $description);
|
||||
$room_id = Room_create($name, $map_url, $description, $dect);
|
||||
} else {
|
||||
Room_update($room_id, $name, $map_url, $description);
|
||||
Room_update($room_id, $name, $map_url, $description, $dect);
|
||||
}
|
||||
|
||||
NeededAngelTypes_delete_by_room($room_id);
|
||||
|
@ -159,6 +165,7 @@ function admin_rooms()
|
|||
div('row', [
|
||||
div('col-md-6', [
|
||||
form_text('name', __('Name'), $name, false, 35),
|
||||
form_text('dect', __('DECT'), $dect),
|
||||
form_text('map_url', __('Map URL'), $map_url),
|
||||
form_info('', __('The map url is used to display an iframe on the room page.')),
|
||||
form_textarea('description', __('Description'), $description),
|
||||
|
@ -222,6 +229,7 @@ function admin_rooms()
|
|||
msg(),
|
||||
table([
|
||||
'name' => __('Name'),
|
||||
'dect' => __('DECT'),
|
||||
'map_url' => __('Map'),
|
||||
'actions' => ''
|
||||
], $rooms)
|
||||
|
|
|
@ -27,6 +27,12 @@ function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, Shift
|
|||
$description .= $parsedown->parse($room->description);
|
||||
}
|
||||
|
||||
$dect = '';
|
||||
if (config('enable_dect') && $room->dect) {
|
||||
$dect = heading(__('Contact'), 3)
|
||||
. description([__('DECT') => sprintf('<a href="tel:%s">%1$s</a>', $room->dect)]);
|
||||
}
|
||||
|
||||
$tabs = [];
|
||||
if ($room->map_url) {
|
||||
$tabs[__('Map')] = sprintf(
|
||||
|
@ -65,6 +71,7 @@ function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, Shift
|
|||
'btn'
|
||||
)
|
||||
]) : '',
|
||||
$dect,
|
||||
$description,
|
||||
tabs($tabs, $selected_tab),
|
||||
], true);
|
||||
|
|
|
@ -13,6 +13,7 @@ use Illuminate\Database\Query\Builder as QueryBuilder;
|
|||
* @property string $name
|
||||
* @property string $map_url
|
||||
* @property string $description
|
||||
* @property string $dect
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
*
|
||||
|
@ -33,6 +34,7 @@ class Room extends BaseModel
|
|||
/** @var array */
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'dect',
|
||||
'map_url',
|
||||
'description',
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue