1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-16 02:10:26 +01:00
openstamanager/modules/checklists/modutil.php

61 lines
2.1 KiB
PHP
Raw Normal View History

2019-07-30 16:50:10 +02:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.n.c.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2019-07-30 16:50:10 +02:00
function renderChecklist($check, $level = 0)
{
$user = auth()->getUser();
2019-07-30 17:15:38 +02:00
$enabled = $check->assignedUsers ? $check->assignedUsers->pluck('id')->search($user->id) !== false : true;
2019-07-30 16:50:10 +02:00
$result = '
2020-09-07 15:04:06 +02:00
<li id="check_'.$check->id.'" class="check-item'.(!empty($check->checked_at) ? ' done' : '').'" '.(!$enabled ? 'style="opacity: 0.4"' : '').' data-id="'.$check->id.'">
2019-07-30 16:50:10 +02:00
<input type="checkbox" value="'.(!empty($check->checked_at) ? '1' : '0').'" '.(!empty($check->checked_at) ? 'checked' : '').'>
<span class="text">'.$check->content.'</span>
2020-11-30 10:32:16 +01:00
<span class="badge pull-right">'.(!empty($check->checked_at) ? 'Verificato da '.$check->checkUser->username.' il '.timestampFormat($check->checked_at) : '').'</span>';
2019-07-30 16:50:10 +02:00
if ($level == 0) {
$result .= '
<span class="handle pull-right">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>';
}
2019-07-30 17:44:15 +02:00
if (empty($check->user) || $check->user->id == $user->id) {
$result .= '
2019-07-30 16:50:10 +02:00
<div class="tools">
<i class="fa fa-trash-o check-delete"></i>
2019-07-30 17:44:15 +02:00
</div>';
}
$result .= '
2019-07-30 16:50:10 +02:00
<ul class="todo-list">';
$children = $check->children;
foreach ($children as $child) {
$result .= renderChecklist($child, $level + 1);
}
$result .= '
</ul>
</li>';
return $result;
}