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
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
if (!function_exists('renderChecklist')) {
|
|
|
|
function renderChecklist($check, $level = 1, $parent = 0)
|
|
|
|
{
|
|
|
|
global $structure;
|
|
|
|
|
|
|
|
$user = auth()->getUser();
|
2024-01-15 15:30:45 +01:00
|
|
|
$enabled = $check->assignedUsers ? ($check->assignedUsers->pluck('id')->search($user->id) !== false || $user->idgruppo == 1) : true;
|
2023-12-06 16:48:54 +01:00
|
|
|
|
|
|
|
$margin = ($level * 20);
|
|
|
|
|
|
|
|
$result = '
|
|
|
|
<tr id="check_'.$check->id.'" data-id="'.$check->id.'" class="sortablerow sonof_'.$parent.'" >
|
|
|
|
<td style="padding-top:0px;padding-bottom:0px;border-top:0px;">
|
|
|
|
<table class="table" style="margin-bottom:0px;">
|
|
|
|
<tr>';
|
|
|
|
if ($check->is_titolo) {
|
|
|
|
$result .= '
|
|
|
|
<td style="width:40px;"></td>
|
|
|
|
<td colspan="3" style="border-top:0px;">
|
|
|
|
<span class="text unblockable"><big>'.$check->content.'</big></span>
|
|
|
|
</td>';
|
|
|
|
} else {
|
|
|
|
$result .= '
|
|
|
|
<td style="width:40px;text-align:center;border-top:0px;border-left:3px solid #eaeaea;">
|
|
|
|
<input type="checkbox" class="checkbox unblockable" data-id="'.$check->id.'" value="'.(!empty($check->checked_at) ? '1' : '0').'" '.(!empty($check->checked_at) ? 'checked' : '').' '.(!$enabled ? 'disabled' : '').'>
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="border-top:0px;">
|
|
|
|
<span class="text unblockable" style="'.(!empty($check->checked_at) ? 'text-decoration:line-through;' : '').'">'.$check->content.' </span>
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="border-top:0px;">
|
2024-05-16 18:02:50 +02:00
|
|
|
<span class="badge badge-default pull-right verificato '.(!$check->checked_at ? 'hidden' : '').'" style="margin-right:5px;padding:6px 8px;">'.(!empty($check->checked_at) ? tr('Verificato da _NAME_ il _DATE_', [
|
2024-03-22 15:52:24 +01:00
|
|
|
'_NAME_' => $check->checkUser->username,
|
|
|
|
'_DATE_' => timestampFormat($check->checked_at),
|
|
|
|
]) : '').'
|
2023-12-06 16:48:54 +01:00
|
|
|
</span>
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="width:500px;border-top:0px;">
|
|
|
|
{[ "type": "textarea", "class": "unblockable", "name": "note_checklist", "placeholder": "'.tr('Note').'...", "id": "note_'.$check->id.'", "value": "'.$check->note.'" ]}
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="width:150px;border-top:0px;">
|
|
|
|
<button class="btn btn-default btn-xs '.(!$enabled ? 'disabled' : '').' save-nota" onclick="saveNota(\''.$check->id.'\')"><i class="fa fa-check"></i> '.tr('Salva nota').'</button>';
|
|
|
|
|
|
|
|
if (intval($check->assignedUsers->pluck('id')->toArray()) > 0) {
|
2024-05-16 18:02:50 +02:00
|
|
|
$result .= ' <span class="badge badge-info pull-right" style="padding:6px 8px;" data-widget="tooltip" title="Assegnato a '.implode(', ', $check->assignedUsers->pluck('username')->toArray()).'"><i class="fa fa-user"></i></span>';
|
2023-12-06 16:48:54 +01:00
|
|
|
} else {
|
2024-05-16 18:02:50 +02:00
|
|
|
$result .= ' <span class="badge badge-danger pull-right" style="padding:6px 8px;" data-widget="tooltip" title="'.tr('Nessun utente assegnato').'"><i class="fa fa-user-times"></i></span>';
|
2023-12-06 16:48:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
</td>';
|
|
|
|
}
|
2023-10-27 15:09:49 +02:00
|
|
|
|
2023-07-18 17:08:33 +02:00
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
<td style="width:10px;text-align:center;border-top:0px;">
|
|
|
|
<div class="input-group-btn">
|
|
|
|
<button class="btn btn-warning btn-xs '.(!$enabled ? 'disabled' : '').'" onclick="edit_check(\''.$check->id.'\')"><i class="fa fa-edit"></i></button>
|
|
|
|
<button class="btn btn-danger btn-xs '.(!$enabled ? 'disabled' : '').'" onclick="delete_check(\''.$check->id.'\')"><i class="fa fa-trash"></i></button>
|
|
|
|
<button class="btn btn-xs btn-default handle" title="Modifica ordine delle righe" draggable="true"><i class="fa fa-sort"></i></button>
|
|
|
|
</div>
|
|
|
|
</td>';
|
2023-05-19 17:15:30 +02:00
|
|
|
|
2023-07-18 17:08:33 +02:00
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
</tr>';
|
|
|
|
|
|
|
|
if (sizeof($check->children) > 0) {
|
|
|
|
$result .= '
|
|
|
|
<tr>
|
|
|
|
<td colspan="5" style="padding-left:'.$margin.'px;padding-right:10px;padding-top:0px;padding-bottom:0px;border-top:0px;">
|
|
|
|
<table class="table" style="margin-bottom:0px;">
|
|
|
|
<tbody class="sort" data-sonof="'.$check->id.'">';
|
|
|
|
$children = $structure->checks()->where('id_parent', $check->id)->orderBy('order')->get();
|
|
|
|
foreach ($children as $child) {
|
|
|
|
$result .= renderChecklist($child, $level + 1, $check->id);
|
|
|
|
}
|
|
|
|
$result .= '
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
2023-07-18 17:08:33 +02:00
|
|
|
}
|
2023-02-20 19:01:24 +01:00
|
|
|
|
2023-07-18 17:08:33 +02:00
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
return $result;
|
2023-08-04 14:54:28 +02:00
|
|
|
}
|
2023-12-06 16:48:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!function_exists('renderChecklistInserimento')) {
|
|
|
|
function renderChecklistInserimento($check, $level = 1, $parent = 0)
|
|
|
|
{
|
|
|
|
global $record;
|
2019-07-30 17:44:15 +02:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
$margin = ($level * 20);
|
2023-02-27 11:14:58 +01:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
$result = '
|
|
|
|
<tr id="check_'.$check->id.'" data-id="'.$check->id.'" class="sortablerow sonof_'.$parent.'" >
|
|
|
|
<td style="padding-top:0px;padding-bottom:0px;border-top:0px;">
|
|
|
|
<table class="table" style="margin-bottom:0px;">
|
|
|
|
<tr>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
<td style="width:40px;border-top:0px;border-left:3px solid #eaeaea;">';
|
2023-02-27 11:14:58 +01:00
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
<span class="text">'.$check->content.'</span>';
|
|
|
|
$result .= '
|
|
|
|
</td>';
|
2023-03-13 16:22:50 +01:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
$result .= '
|
|
|
|
<td style="width:40px;text-align:right;border-top:0px;">
|
|
|
|
<div class="input-group-btn">
|
|
|
|
<button class="btn btn-warning btn-xs" onclick="edit_check(\''.$check->id.'\')"><i class="fa fa-edit"></i></button>
|
|
|
|
<button class="btn btn-danger btn-xs" onclick="delete_check(\''.$check->id.'\')"><i class="fa fa-trash"></i></button>
|
|
|
|
</div>
|
|
|
|
</td>';
|
2023-03-13 16:22:50 +01:00
|
|
|
|
|
|
|
$result .= '
|
2023-12-06 16:48:54 +01:00
|
|
|
</tr>';
|
|
|
|
|
|
|
|
if (sizeof($check->children) > 0) {
|
|
|
|
$result .= '
|
|
|
|
<tr>
|
|
|
|
<td colspan="4" style="padding-left:'.$margin.'px;padding-right:0px;padding-top:0px;padding-bottom:0px;border-top:0px;">
|
|
|
|
<table class="table" style="margin-bottom:0px;">
|
|
|
|
<tbody class="sort" data-sonof="'.$check->id.'">';
|
|
|
|
$children = $record->checks()->where('id_parent', $check->id)->orderBy('order')->get();
|
|
|
|
foreach ($children as $child) {
|
|
|
|
$result .= renderChecklistInserimento($child, $level + 1, $check->id);
|
|
|
|
}
|
|
|
|
$result .= '
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
2023-08-04 14:54:28 +02:00
|
|
|
}
|
2023-03-13 16:22:50 +01:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
$result .= '
|
|
|
|
</table>
|
|
|
|
</td>
|
2023-03-13 16:22:50 +01:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
<td style="width:40px;text-align:center;border-top:0px;">
|
|
|
|
<button class="btn btn-xs btn-default handle" title="Modifica ordine delle righe" draggable="true">
|
|
|
|
<i class="fa fa-sort"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
2023-02-27 11:14:58 +01:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
</tr>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
return $result;
|
|
|
|
}
|
2019-07-30 16:50:10 +02:00
|
|
|
}
|
2022-04-04 17:58:46 +02:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
if (!function_exists('renderChecklistHtml')) {
|
|
|
|
function renderChecklistHtml($check, $level = 0)
|
|
|
|
{
|
|
|
|
$user = auth()->getUser();
|
|
|
|
$enabled = $check->assignedUsers ? $check->assignedUsers->pluck('id')->search($user->id) !== false : true;
|
|
|
|
|
|
|
|
$width = 10 + 20 * $level;
|
|
|
|
|
|
|
|
$result = '
|
|
|
|
<tr>
|
|
|
|
<td class="text-center" style="width:30px;">
|
|
|
|
'.(!empty($check->checked_at) ? '<img src="'.ROOTDIR.'/templates/interventi/check.png" style="width:10px;">' : '').'
|
|
|
|
</td>
|
|
|
|
<td style="padding-left:'.$width.'px;">
|
|
|
|
<span class="text"><b>'.$check->content.'</b>'.(!empty($check->value) ? ': '.$check->value : '').'</span>
|
|
|
|
</td>
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
$children = $check->children;
|
|
|
|
foreach ($children as $child) {
|
|
|
|
$result .= renderChecklistHtml($child, $level + 1);
|
|
|
|
}
|
2022-04-04 17:58:46 +02:00
|
|
|
|
2023-12-06 16:48:54 +01:00
|
|
|
return $result;
|
|
|
|
}
|
2023-08-04 14:54:28 +02:00
|
|
|
}
|