.
*/
function renderChecklist($check, $level = 1, $parent = 0) {
global $structure;
$user = auth()->getUser();
$enabled = $check->assignedUsers ? ($check->assignedUsers->pluck('id')->search($user->id) !== false || ($user->idgruppo) == 1): true;
$margin = ($level*20);
$result = '
';
if (sizeof($check->children)>0 && setting('Utilizzare checklist genitore come titolo')) {
$result .= '
|
'.$check->content.'
| ';
} else {
$result .= '
checked_at) ? 'checked' : '').' '.(!$enabled ? 'disabled' : '').'>
| ';
$result .= '
'.$check->content.'
| ';
$result .= '
{[ "type": "textarea", "class": "unblockable", "name": "note_checklist", "placeholder": "'.tr('Note').'...", "id": "'.$check->id.'", "value": "'.$check->note.'" ]}
| ';
$result .= '
';
if (intval($check->assignedUsers->pluck('id')->toArray())>0) {
$result .= ' ';
} else {
$result .= ' '. tr('Nessun utente assegnato').'';
}
if (!empty($check->checked_at)) {
$result .= '
'.(!empty($check->checked_at) ? tr('Verificato da _NAME_ il _DATE_', [
'_NAME_' => $check->checkUser->username,
'_DATE_' => timestampFormat($check->checked_at),
]) : '').'
';
}
$result .= '
| ';
}
$result .= '
| ';
$result .= '
';
if(sizeof($check->children)>0){
$result .= '
';
$children = $structure->checks()->where('id_parent', $check->id)->orderBy('order')->get();
foreach ($children as $child) {
$result .= renderChecklist($child, $level + 1, $check->id);
}
$result .= '
|
';
}
$result .= '
|
';
return $result;
}
function renderChecklistInserimento($check, $level = 1, $parent = 0)
{
global $record;
$margin = ($level*20);
$result = '
';
$result .= '
';
$result .= '
'.$check->content.'';
$result .= '
| ';
$result .= '
| ';
$result .= '
';
if(sizeof($check->children)>0){
$result .= '
';
$children = $record->checks()->where('id_parent', $check->id)->orderBy('order')->get();
foreach ($children as $child) {
$result .= renderChecklistInserimento($child, $level + 1, $check->id);
}
$result .= '
|
';
}
$result .= '
|
|
';
return $result;
}
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 = '
'.(!empty($check->checked_at)?'':'').'
|
'.$check->content.''.(!empty($check->value)?': '.$check->value:'').'
|
';
$children = $check->children;
foreach ($children as $child) {
$result .= renderChecklistHtml($child, $level + 1);
}
return $result;
}