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