Gestione checklist plugin Impianti

This commit is contained in:
MatteoPistorello 2023-10-27 15:09:49 +02:00
parent 543e39d6cc
commit 9b0e6947b0
11 changed files with 371 additions and 102 deletions

View File

@ -19,6 +19,10 @@
include_once __DIR__.'/../../core.php';
use Modules\Checklists\Check;
$modulo_impianti = Modules::get('Impianti');
switch (filter('op')) {
case 'update':
$nome = filter('nome');
@ -73,5 +77,22 @@ switch (filter('op')) {
flash()->error(tr('Esistono ancora alcuni articoli sotto questa categoria!'));
}
break;
case 'sync_checklist':
$checks_categoria = $dbo->fetchArray('SELECT * FROM zz_checks WHERE id_module = '.prepare($id_module).' AND id_record = '.prepare($id_record));
$impianti = $dbo->select('my_impianti', '*', [], ['id_categoria' => $id_record]);
foreach ($impianti as $impianto) {
foreach ($checks_categoria as $check_categoria) {
$check = Check::build($user, $structure, $impianto['id'], $check_categoria['content'], null, $check_categoria['is_titolo'], $check_categoria['order']);
$check->id_module = $modulo_impianti['id'];
$check->id_plugin = null;
$check->note = $check_categoria['note'];
$check->save();
}
}
flash()->info(tr('Impianti sincronizzati correttamente!'));
break;
}

View File

@ -0,0 +1,30 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../core.php';
echo '
<button type="button" class="btn btn-primary" onclick="if( confirm(\'Confermando, tutte le checklist degli impianti di questa categoria verranno aggiornate. Continuare?\') ){ $(\'#check-impianto\').submit(); }"> <i class="fa fa-refresh"></i> '.tr('Sincronizza checklist impianti').'</button>';
// Sincronizza checklist impianti
echo '
<form action="" method="post" id="check-impianto">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="sync_checklist">
</form>';

View File

@ -48,29 +48,30 @@ function renderChecklist($check, $level = 1, $parent = 0)
<span class="text unblockable" style="'.(!empty($check->checked_at) ? 'text-decoration:line-through;' : '').'">'.$check->content.' </span>
</td>';
$result .= '
<td style="border-top:0px;">
<span class="label label-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_', [
'_NAME_' => $check->checkUser->username,
'_DATE_' => timestampFormat($check->checked_at),
]) : '').'
</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:250px;border-top:0px;">
<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) {
$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>';
} else {
$result .= ' <span class="label label-danger pull-right" style="padding:6px 8px;">'.tr('Nessun utente assegnato').'</span>';
$result .= ' <span class="label label-danger pull-right" style="padding:6px 8px;" data-toggle="tooltip" title="'.tr('Nessun utente assegnato').'"><i class="fa fa-user-times"></i></span>';
}
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>';
}
$result .= '
</td>';
}

View File

@ -46,7 +46,7 @@ class Check extends Model
*
* @return self
*/
public static function build(User $user, $structure, $id_record, $content, $parent_id = null, $is_titolo = 0, $order = 99)
public static function build(User $user, $structure, $id_record, $content, $parent_id = null, $is_titolo = 0, $order = 99, $id_module_from = 0, $id_record_from = 0)
{
$model = new static();
@ -66,6 +66,9 @@ class Check extends Model
// Ordinamento temporaneo alla creazione
$model->order = $order;
$model->id_module_from = $id_module_from;
$model->id_record_from = $id_record_from;
$model->save();
return $model;

View File

@ -31,12 +31,12 @@ trait ChecklistTrait
public function recordChecks($id_record)
{
return $this->checks()->where('id_record', $id_record)->orderBy('order')->get();
return $this->checks()->where('id_record', $id_record)->where('id_module_from', 0)->orderBy('order')->get();
}
public function mainChecks($id_record)
{
return $this->checks()->where('id_record', $id_record)->whereNull('id_parent')->orderBy('order')->get();
return $this->checks()->where('id_record', $id_record)->where('id_module_from', 0)->whereNull('id_parent')->orderBy('order')->get();
}
public function checklists()

View File

@ -19,9 +19,12 @@
include_once __DIR__.'/../../core.php';
use Modules\Checklists\Check;
$op = post('op');
$upload_dir = base_dir().'/files/'.Modules::get('Impianti')['directory'];
$modulo_categorie_impianti = Modules::get('Categorie impianti');
switch ($op) {
// Aggiorno informazioni di base impianto
@ -96,12 +99,21 @@ switch ($op) {
$nome = post('nome');
$idtecnico = post('idtecnico');
$idsede = post('idsede');
$id_categoria = post('id_categoria');
if (!empty($matricola)) {
$dbo->query('INSERT INTO my_impianti(matricola, idanagrafica, nome, data, idtecnico, idsede) VALUES ('.prepare($matricola).', '.prepare($idanagrafica).', '.prepare($nome).', NOW(), '.prepare($idtecnico).', '.prepare($idsede).')');
$dbo->query('INSERT INTO my_impianti(matricola, idanagrafica, nome, data, idtecnico, idsede, id_categoria) VALUES ('.prepare($matricola).', '.prepare($idanagrafica).', '.prepare($nome).', NOW(), '.prepare($idtecnico).', '.prepare($idsede).', '.prepare($id_categoria).')');
$id_record = $dbo->lastInsertedID();
$checks_categoria = $dbo->fetchArray('SELECT * FROM zz_checks WHERE id_module = '.prepare($modulo_categorie_impianti['id']).' AND id_record = '.prepare($id_categoria));
foreach ($checks_categoria as $check_categoria) {
$check = Check::build($user, $structure, $id_record, $check_categoria['content'], null, $check_categoria['is_titolo'], $check_categoria['order']);
$check->id_plugin = null;
$check->note = $check_categoria['note'];
$check->save();
}
if (isAjaxRequest()) {
echo json_encode(['id' => $id_record, 'text' => $matricola.' - '.$nome]);
}
@ -153,6 +165,19 @@ switch ($op) {
flash()->info(tr('Impianto e relativi componenti eliminati!'));
break;
case 'sync_checklist':
$checks_categoria = $dbo->fetchArray('SELECT * FROM zz_checks WHERE id_module = '.prepare($modulo_categorie_impianti['id']).' AND id_record = '.prepare(post('id_categoria')));
foreach ($checks_categoria as $check_categoria) {
$check = Check::build($user, $structure, $id_record, $check_categoria['content'], null, $check_categoria['is_titolo'], $check_categoria['order']);
$check->id_plugin = null;
$check->note = $check_categoria['note'];
$check->save();
}
flash()->info(tr('Checklist importate correttamente!'));
break;
}
// Operazioni aggiuntive per l'immagine

View File

@ -33,18 +33,26 @@ $id_anagrafica = filter('id_anagrafica');
<div class="col-md-8">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1 ]}
</div>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "id": "idanagrafica_impianto", "required": 1, "value": "<?php echo $id_anagrafica; ?>", "ajax-source": "clienti", "icon-after": "add|<?php echo Modules::get('Anagrafiche')['id']; ?>|tipoanagrafica=Cliente&readonly_tipo=1||<?php echo !empty($id_anagrafica) ? 'disabled' : ''; ?>", "readonly": "<?php echo !empty($id_anagrafica) ? 1 : 0; ?>" ]}
</div>
<div class="col-md-4">
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Sede'); ?>", "name": "idsede", "value": "$idsede$", "ajax-source": "sedi", "select-options": <?php echo json_encode(['idanagrafica' => $id_anagrafica]); ?>, "placeholder": "Sede legale" ]}
</div>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Tecnico predefinito'); ?>", "name": "idtecnico", "ajax-source": "tecnici", "icon-after": "add|<?php echo Modules::get('Anagrafiche')['id']; ?>|tipoanagrafica=Tecnico&readonly_tipo=1" ]}
</div>
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "id_categoria", "required": 0, "value": "$id_categoria$", "values": "query=SELECT id, nome AS descrizione FROM my_impianti_categorie", "icon-after": "add|<?php echo Modules::get('Categorie impianti')['id']; ?>" ]}
</div>
</div>
<!-- PULSANTI -->

View File

@ -20,7 +20,9 @@
include_once __DIR__.'/../../core.php';
echo '
<button type="button" class="btn btn-primary" onclick="if( confirm(\'Duplicare questo impianto?\') ){ $(\'#copia-impianto\').submit(); }"> <i class="fa fa-copy"></i> '.tr('Duplica impianto').'</button>';
<button type="button" class="btn btn-primary" onclick="if( confirm(\'Duplicare questo impianto?\') ){ $(\'#copia-impianto\').submit(); }"> <i class="fa fa-copy"></i> '.tr('Duplica impianto').'</button>
<button type="button" class="btn btn-primary" onclick="if( confirm(\'Confermando, tutte le checklist della categoria verranno importate in questo impianto. Continuare?\') ){ $(\'#check-impianto\').submit(); }"> <i class="fa fa-refresh"></i> '.tr('Importa checklist categoria').'</button>';
// Duplica impianto
echo '
@ -28,3 +30,11 @@ echo '
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="copy">
</form>';
// Importa checklist categoria
echo '
<form action="" method="post" id="check-impianto">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="sync_checklist">
<input type="hidden" name="id_categoria" value="'.$record['id_categoria'].'">
</form>';

View File

@ -19,7 +19,11 @@
include_once __DIR__.'/../../../core.php';
use Modules\Checklists\Check;
$matricole = (array) post('matricole');
$modulo_impianti = Modules::get('Impianti');
$checklist_module = Modules::get('Checklists');
// Salvo gli impianti selezionati
if (filter('op') == 'link_impianti') {
@ -30,6 +34,12 @@ if (filter('op') == 'link_impianti') {
foreach ($matricole_old as $matricola) {
if (!in_array($matricola, $matricole)) {
$dbo->query('DELETE FROM my_impianti_interventi WHERE idintervento='.prepare($id_record).' AND idimpianto = '.prepare($matricola));
Check::deleteLinked([
'id_module' => $id_module,
'id_record' => $id_record,
'id_module_from' => $modulo_impianti['id'],
'id_record_from' => $matricola
]);
$components = $dbo->fetchArray('SELECT * FROM my_componenti WHERE id_impianto = '.prepare($matricola));
if (!empty($components)) {
@ -43,6 +53,15 @@ if (filter('op') == 'link_impianti') {
foreach ($matricole as $matricola) {
if (!in_array($matricola, $matricole_old)) {
$dbo->query('INSERT INTO my_impianti_interventi(idimpianto, idintervento) VALUES('.prepare($matricola).', '.prepare($id_record).')');
$checks_impianti = $dbo->fetchArray('SELECT * FROM zz_checks WHERE id_module = '.prepare( $modulo_impianti['id']).' AND id_record = '.prepare($matricola));
foreach ($checks_impianti as $check_impianto) {
$check = Check::build($user, $structure, $id_record, $check_impianto['content'], null, $check_impianto['is_titolo'], $check_impianto['order'], $modulo_impianti['id'], $matricola);
$check->id_module = $id_module;
$check->id_plugin = null;
$check->note = $check_impianto['note'];
$check->save();
}
}
}
@ -72,83 +91,8 @@ if ($is_completato) {
$disabled = '';
}
// IMPIANTI
echo '
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">'.tr('Impianti soggetti ad intervento').'</h3>
</div>
<div class="box-body">';
$impianti_collegati = $dbo->fetchArray('SELECT * FROM my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto = my_impianti.id WHERE idintervento = '.prepare($id_record));
echo '
<div class="row">';
foreach ($impianti_collegati as $impianto) {
echo '
<div class="col-md-4">
<table class="table table-hover table-condensed table-striped">';
// MATRICOLA
echo '
<tr>
<td class="text-right" width="25%">'.tr('Matricola').':</td>
<td valign="top">'.$impianto['matricola'].'</td>
</tr>';
// NOME
echo '
<tr>
<td class="text-right">'.tr('Nome').':</td>
<td valign="top">
'.Modules::link('Impianti', $impianto['id'], $impianto['nome']).'
</td>
</tr>';
// DATA
echo '
<tr>
<td class="text-right">'.tr('Data').':</td>
<td valign="top">'.dateFormat($impianto['data']).'</td>
</tr>';
// DESCRIZIONE
echo '
<tr>
<td class="text-right">'.tr('Descrizione').':</td>
<td valign="top">'.$impianto['descrizione'].'</td>
</tr>';
echo '
<tr>
<td valign="top" class="text-right">'.tr("Componenti soggetti all'intervento").'</td>
<td valign="top">
<form action="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'&op=link_componenti&matricola='.$impianto['id'].'" method="post">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_impianto" value="'.$impianto['id'].'">';
$inseriti = $dbo->fetchArray('SELECT * FROM my_componenti_interventi WHERE id_intervento = '.prepare($id_record));
$ids = array_column($inseriti, 'id_componente');
echo '
{[ "type": "select", "label": "'.tr('Componenti').'", "multiple": 1, "name": "componenti[]", "id": "componenti_'.$impianto['id'].'", "ajax-source": "componenti", "select-options": {"matricola": '.$impianto['id'].'}, "value": "'.implode(',', $ids).'", "readonly": "'.!empty($readonly).'", "disabled": "'.!empty($disabled).'" ]}
<button type="submit" class="btn btn-success" '.$disabled.'>
<i class="fa fa-check"></i> '.tr('Salva componenti').'
</button>
</form>
</td>
</tr>
</table>
</div>';
}
echo '
</div>';
/*
Aggiunta impianti all'intervento
* Aggiunta impianti all'intervento
*/
// Elenco impianti collegati all'intervento
$impianti = $dbo->fetchArray('SELECT idimpianto FROM my_impianti_interventi WHERE idintervento='.prepare($id_record));
@ -161,17 +105,228 @@ echo '
<form action="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'&op=link_impianti" method="post">
<input type="hidden" name="backto" value="record-edit">
<div class="row">
<div class="col-xs-12 col-md-6">
{[ "type": "select", "name": "matricole[]", "label": "'.tr('Impianti').'", "multiple": 1, "value": "'.implode(',', $impianti).'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.$record['idanagrafica'].', "idsede_destinazione": '.($record['idsede_destinazione'] ?: '""').'}, "extra": "'.$readonly.'", "icon-after": "add|'.Modules::get('Impianti')['id'].'|id_anagrafica='.$record['idanagrafica'].'" ]}
<div class="col-md-12">
{[ "type": "select", "name": "matricole[]", "label": "'.tr('Impianti').'", "multiple": 1, "value": "'.implode(',', $impianti).'", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": '.$record['idanagrafica'].', "idsede_destinazione": '.($record['idsede_destinazione'] ?: '""').'}, "extra": "'.$readonly.'", "icon-after": "add|'.$modulo_impianti['id'].'|id_anagrafica='.$record['idanagrafica'].'" ]}
</div>
</div>
<br><br>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-success pull-right" '.$disabled.'><i class="fa fa-check"></i> '.tr('Salva impianti').'</button>
</div>
</div>
</form>
<br>';
<button type="button" class="btn btn-primary hide" data-toggle="modal" data-title="'.tr('Aggiungi impianto').'" data-href="'.base_path().'/add.php?id_module='.Modules::get('Impianti')['id'].'&source=Attività&select=idimpianti&id_anagrafica='.$record['idanagrafica'].'&ajax=yes"><i class="fa fa-plus"></i> '.tr('Aggiungi impianto').'</button>
if (!empty($impianti)) {
// IMPIANTI
echo '
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">'.tr('Impianti soggetti ad intervento').'</h3>
</div>
<div class="box-body">
<table class="table table-hover table-condensed table-striped">
<tr>
<th class="text-center" width="1%"></th>
<th class="text-center" width="10%">'.tr('Matricola').'</th>
<th class="text-center" width="20%">'.tr('Nome').'</th>
<th class="text-center" width="5%">'.tr('Data').'</th>
<th class="text-center">'.tr('Descrizione').'</th>
<th class="text-center" width="25%">'.tr("Componenti soggetti all'intervento").'</th>
<th class="text-center" width="5%">Checklist</th>
</tr>';
</form>';
$impianti_collegati = $dbo->fetchArray('SELECT * FROM my_impianti_interventi INNER JOIN my_impianti ON my_impianti_interventi.idimpianto = my_impianti.id WHERE idintervento = '.prepare($id_record));
foreach ($impianti_collegati as $impianto) {
$checks = Check::where('id_module_from', $modulo_impianti['id'])->where('id_record_from', $impianto['id'])->where('id_module', $id_module)->where('id_record', $id_record)->get();
$type = 'muted';
$class = 'disabled';
$icon = 'circle-o';
$icon2 = 'remove';
if (sizeof($checks)) {
$class = '';
$icon = 'plus';
$checks_not_verified = $checks->where('checked_at', null)->first();
$type = sizeof($checks_not_verified) ? 'warning' : 'success';
$icon2 = sizeof($checks_not_verified) ? 'clock-o' : 'check';
}
echo '
<tr>
<td class="text-left">
<button type="button" class="btn btn-xs btn-default '.$class.'" onclick="toggleDettagli(this)">
<i class="fa fa-'.$icon.'"></i>
</button>
</td>
<td>'.$impianto['matricola'].'</td>
<td>'.Modules::link('Impianti', $impianto['id'], $impianto['nome']).'</td>
<td class="text-center">'.dateFormat($impianto['data']).'</td>
<td>'.$impianto['descrizione'].'</td>
<td>
<form action="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$id_record.'&op=link_componenti&matricola='.$impianto['id'].'" method="post">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_impianto" value="'.$impianto['id'].'">';
$inseriti = $dbo->fetchArray('SELECT * FROM my_componenti_interventi WHERE id_intervento = '.prepare($id_record));
$ids = array_column($inseriti, 'id_componente');
echo '
{[ "type": "select", "multiple": 1, "name": "componenti[]", "id": "componenti_'.$impianto['id'].'", "ajax-source": "componenti", "select-options": {"matricola": '.$impianto['id'].'}, "value": "'.implode(',', $ids).'", "readonly": "'.!empty($readonly).'", "disabled": "'.!empty($disabled).'", "icon-after": "<button type=\"submit\" class=\"btn btn-success\" '.$disabled.'> <i class=\"fa fa-check\"></i> '.tr('Salva').'</button>" ]}
</form>
</td>
<td class="text-center"><br><i class="fa fa-'.$icon2.' fa-2x text-'.$type.'"></i></td>
</tr>
<tr style="display: none">
<td colspan="6">
<table class="table">
<tbody class="sort check-impianto" data-sonof="0">';
foreach ($checks as $check) {
echo renderChecklist($check);
}
echo '
</tbody>
</table>
</td>
</tr>';
}
echo '
</table>
</div>
</div>';
} else {
echo '
<div class="alert alert-info text-center">
<i class="fa fa-info-circle"></i> '.tr('Nessun impianto collegato a questo intervento').'
</div>';
}
echo '
</div>
</div>';
echo '
<script>
function toggleDettagli(trigger) {
const tr = $(trigger).closest("tr");
const dettagli = tr.next();
if (dettagli.css("display") === "none"){
dettagli.show(500);
$(trigger).children().removeClass("fa-plus");
$(trigger).children().addClass("fa-minus");
} else {
dettagli.hide(500);
$(trigger).children().removeClass("fa-minus");
$(trigger).children().addClass("fa-plus");
}
}
</script>';
echo '
<script>$(document).ready(init)</script>
<script>
$(document).ready(function(){
$("[data-toggle=\'tooltip\']").tooltip();
});
sortable("#tab_checks .sort", {
axis: "y",
handle: ".handle",
cursor: "move",
dropOnEmpty: true,
scroll: true,
});
sortable_table = sortable("#tab_checks .sort").length;
for(i=0; i<sortable_table; i++){
sortable("#tab_checks .sort")[i].addEventListener("sortupdate", function(e) {
var sonof = $(this).data("sonof");
let order = $(this).find(".sonof_"+sonof+"[data-id]").toArray().map(a => $(a).data("id"))
$.post("'.$checklist_module->fileurl('ajax.php').'", {
op: "update_position",
order: order.join(","),
});
});
}
$("textarea[name=\'note_checklist\']").keyup(function() {
$(this).parent().parent().parent().find(".save-nota").removeClass("btn-default");
$(this).parent().parent().parent().find(".save-nota").addClass("btn-success");
});
function saveNota(id) {
$.post("'.$checklist_module->fileurl('ajax.php').'", {
op: "save_note",
note: $("#note_" + id).val(),
id: id
}, function() {
alertPush();
$("#note_" + id).parent().parent().parent().find(".save-nota").removeClass("btn-success");
$("#note_" + id).parent().parent().parent().find(".save-nota").addClass("btn-default");
});
}
$(".check-impianto .checkbox").click(function(){
if($(this).is(":checked")){
$.post("'.$checklist_module->fileurl('ajax.php').'", {
op: "save_checkbox",
id: $(this).attr("data-id"),
},function(result){
});
$(this).parent().parent().find(".text").css("text-decoration", "line-through");
parent = $(this).attr("data-id");
$("tr.sonof_"+parent).find("input[type=checkbox]").each(function(){
if(!$(this).is(":checked")){
$(this).click();
}
});
$(this).parent().parent().find(".verificato").removeClass("hidden");
$(this).parent().parent().find(".verificato").text("'.tr('Verificato da _USER_ il _DATE_', [
'_USER_' => $user->username,
'_DATE_' => dateFormat(date('Y-m-d')).' '.date('H:i'),
]).'");
}else{
$.post("'.$checklist_module->fileurl('ajax.php').'", {
op: "remove_checkbox",
id: $(this).attr("data-id"),
},function(result){
});
$(this).parent().parent().find(".text").css("text-decoration", "none");
parent = $(this).attr("data-id");
$("tr.sonof_"+parent).find("input[type=checkbox]").each(function(){
if($(this).is(":checked")){
$(this).click();
}
});
$(this).parent().parent().find(".verificato").addClass("hidden");
}
})
function delete_check(id){
if(confirm("Eliminare questa checklist?")){
$.post("'.$checklist_module->fileurl('ajax.php').'", {
op: "delete_check",
id: id,
}, function(){
location.reload();
});
}
}
function edit_check(id){
launch_modal("Modifica checklist", "'.$checklist_module->fileurl('components/edit-check.php').'?id_record="+id, 1);
}
</script>';

View File

@ -22,6 +22,7 @@ include_once __DIR__.'/../../core.php';
use Carbon\CarbonPeriod;
use Modules\Anagrafiche\Anagrafica;
use Modules\Articoli\Articolo as ArticoloOriginale;
use Modules\Checklists\Check;
use Modules\Emails\Mail;
use Modules\Emails\Template;
use Modules\Impianti\Impianto;
@ -37,6 +38,8 @@ use Plugins\ComponentiImpianti\Componente;
use Plugins\ListinoClienti\DettaglioPrezzo;
use Plugins\PianificazioneInterventi\Promemoria;
$modulo_impianti = Modules::get('Impianti');
switch (post('op')) {
case 'update':
$idcontratto = post('idcontratto');
@ -227,6 +230,15 @@ switch (post('op')) {
'idintervento' => $id_record,
'idimpianto' => $impianto,
]);
$checks_impianti = $dbo->fetchArray('SELECT * FROM zz_checks WHERE id_module = '.prepare( $modulo_impianti['id']).' AND id_record = '.prepare($impianto));
foreach ($checks_impianti as $check_impianto) {
$check = Check::build($user, $structure, $id_record, $check_impianto['content'], null, $check_impianto['is_titolo'], $check_impianto['order'], $modulo_impianti['id'], $impianto);
$check->id_module = $id_module;
$check->id_plugin = null;
$check->note = $check_impianto['note'];
$check->save();
}
}
// Collegamenti intervento/componenti

View File

@ -51,3 +51,7 @@ INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `ord
-- Aggiunta impostazione Giorni di preavviso di default alla creazione di un contratto
INSERT INTO `zz_settings` (`nome`, `valore`, `tipo`, `editable`, `sezione`, `order`, `help`) VALUES ("Giorni di preavviso di default", '2', 'decimal', 1, 'Contratti', 3, 'Inserire il numero di giorni di preavviso da impostare automaticamente alla creazione di un contratto.');
-- Checklist plugin Impianti
ALTER TABLE `zz_checks` ADD `id_module_from` INT NOT NULL AFTER `id`, ADD `id_record_from` INT NOT NULL AFTER `id_module_from`;
UPDATE `zz_modules` SET `use_checklists` = '1' WHERE `zz_modules`.`name` = 'Categorie impianti';