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-02-27 11:14:58 +01:00
|
|
|
function renderChecklist($check, $level = 1, $parent = 0) {
|
|
|
|
|
|
|
|
global $structure;
|
|
|
|
|
2019-07-30 16:50:10 +02:00
|
|
|
$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
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
$margin = ($level*20);
|
|
|
|
|
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>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="width:40px;text-align:center;border-top:0px;border-left:3px solid #eaeaea;">
|
|
|
|
<input type="checkbox" class="checkbox" data-id="'.$check->id.'" value="'.(!empty($check->checked_at) ? '1' : '0').'" '.(!empty($check->checked_at) ? 'checked' : '').' '.(!$enabled ? 'disabled' : '').'>
|
|
|
|
</td>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
$result .= '
|
|
|
|
<td style="border-top:0px;">
|
|
|
|
<span class="text">'.$check->content.' </span>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2023-02-20 19:01:24 +01:00
|
|
|
if (intval($check->assignedUsers->pluck('id')->toArray())>0){
|
2023-02-27 11:14:58 +01:00
|
|
|
$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-02-20 19:01:24 +01:00
|
|
|
}else{
|
2023-02-27 11:14:58 +01:00
|
|
|
$result .= ' <span class="label label-danger pull-right" style="padding:6px 8px;">'. tr('Nessun utente assegnato').'</span>';
|
2023-02-20 19:01:24 +01:00
|
|
|
}
|
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
if(!empty($check->checked_at)){
|
|
|
|
$result .= '
|
|
|
|
<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>';
|
2019-07-30 17:44:15 +02:00
|
|
|
}
|
2023-02-27 11:14:58 +01:00
|
|
|
$result .= '
|
|
|
|
</td>';
|
2019-07-30 17:44:15 +02:00
|
|
|
|
2020-12-02 11:31:52 +01:00
|
|
|
$result .= '
|
2023-02-27 11:14:58 +01:00
|
|
|
<td style="width:40px;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>
|
|
|
|
</div>
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
|
2020-12-04 15:40:47 +01:00
|
|
|
|
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-02-27 11:14:58 +01:00
|
|
|
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 = $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>';
|
2019-07-30 16:50:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$result .= '
|
2023-02-27 11:14:58 +01:00
|
|
|
</table>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td style="width:40px;text-align:center;border-top:0px;">
|
2023-03-13 16:22:50 +01:00
|
|
|
<button class="btn btn-xs btn-default handle" title="Modifica ordine delle righe" draggable="true">
|
|
|
|
<i class="fa fa-sort"></i>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
</tr>';
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderChecklistInserimento($check, $level = 1, $parent = 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
global $record;
|
|
|
|
|
|
|
|
$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>';
|
|
|
|
|
|
|
|
$result .= '
|
|
|
|
<td style="width:40px;border-top:0px;border-left:3px solid #eaeaea;">';
|
|
|
|
$result .= '
|
|
|
|
<span class="text">'.$check->content.'</span>';
|
|
|
|
$result .= '
|
|
|
|
</td>';
|
|
|
|
|
|
|
|
$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>';
|
|
|
|
|
|
|
|
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>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$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;
|
|
|
|
|
|
|
|
$width = 10+20*$level;
|
|
|
|
|
|
|
|
$result = '
|
|
|
|
<tr>
|
|
|
|
<td class="text-center" style="width:30px;">
|
2023-03-17 14:58:09 +01: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-02-27 11:14:58 +01: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;
|
|
|
|
}
|