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
|
|
|
|
|
|
|
include_once __DIR__.'/../core.php';
|
2024-03-05 16:01:45 +01:00
|
|
|
use Models\Module;
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2024-04-18 17:44:05 +02:00
|
|
|
$checklist_module = Module::find((new Module())->getByField('title', 'Checklists', Models\Locale::getPredefined()->id));
|
2019-07-30 16:50:10 +02:00
|
|
|
$checks_id = 'checklist_'.$id_module.'_'.$id_plugin;
|
|
|
|
|
|
|
|
echo '
|
2019-07-31 09:25:54 +02:00
|
|
|
<div id="'.$checks_id.'">
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card card-primary">
|
|
|
|
<div class="card-header">
|
|
|
|
<h3 class="card-title">'.tr('Checklist').'</h3>
|
2019-07-31 09:25:54 +02:00
|
|
|
</div>
|
2024-05-16 18:02:50 +02:00
|
|
|
<div class="card-body" style="position:relative">
|
2019-07-31 09:25:54 +02:00
|
|
|
<div id="loading_'.$checks_id.'" class="text-center hide component-loader">
|
|
|
|
<div>
|
|
|
|
<i class="fa fa-refresh fa-spin fa-3x fa-fw"></i>
|
|
|
|
<span class="sr-only">'.tr('Caricamento...').'</span>
|
|
|
|
</div>
|
|
|
|
</div>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
|
|
|
// Form per la creazione di una nuova checklist
|
|
|
|
if ($structure->permission == 'rw') {
|
|
|
|
echo '
|
2019-07-31 09:25:54 +02:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-12">
|
2024-05-16 18:02:50 +02:00
|
|
|
<a class="btn btn-sm btn-primary" data-href="'.$checklist_module->fileurl('components/add-check.php').'?id_module='.$id_module.'&id_record='.$id_record.'&id_plugin='.$id_plugin.'&manager_id='.$checks_id.'" data-widget="tooltip" data-title="'.tr('Aggiungi check').'">
|
2020-11-30 10:32:16 +01:00
|
|
|
<i class="fa fa-plus"></i> '.tr('Nuova').'
|
2019-07-31 09:25:54 +02:00
|
|
|
</a>
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2024-05-16 18:02:50 +02:00
|
|
|
<a class="btn btn-sm btn-primary" data-href="'.$checklist_module->fileurl('components/add-checklist.php').'?id_module='.$id_module.'&id_record='.$id_record.'&id_plugin='.$id_plugin.'&manager_id='.$checks_id.'" data-widget="tooltip" data-title="'.tr('Aggiungi check').'">
|
2020-11-30 10:32:16 +01:00
|
|
|
<i class="fa fa-plus"></i> '.tr('Checklist predefinite').'
|
2019-07-31 09:25:54 +02:00
|
|
|
</a>
|
|
|
|
</div>
|
2019-07-30 16:50:10 +02:00
|
|
|
</div>
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2019-07-31 09:25:54 +02:00
|
|
|
<div class="clearfix"></div>
|
|
|
|
<br>';
|
2019-07-30 16:50:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$checks = $structure->mainChecks($id_record);
|
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
echo " <table class='table'>
|
|
|
|
<tbody class='sort' data-sonof='0'>";
|
|
|
|
foreach ($checks as $check) {
|
|
|
|
echo renderChecklist($check);
|
|
|
|
}
|
2023-08-04 14:54:28 +02:00
|
|
|
echo ' </tbody>
|
|
|
|
</table>';
|
2019-07-30 16:50:10 +02:00
|
|
|
|
2024-01-15 15:30:45 +01:00
|
|
|
echo '
|
2019-07-31 09:25:54 +02:00
|
|
|
</div>
|
2019-07-30 16:50:10 +02:00
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
echo '
|
|
|
|
<script>$(document).ready(init)</script>
|
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
<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",
|
2021-07-20 20:48:02 +02:00
|
|
|
order: order.join(","),
|
|
|
|
});
|
2019-07-30 16:50:10 +02:00
|
|
|
});
|
2023-02-27 11:14:58 +01:00
|
|
|
}
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2023-09-11 16:16:52 +02:00
|
|
|
$("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) {
|
2023-02-27 11:14:58 +01:00
|
|
|
$.post("'.$checklist_module->fileurl('ajax.php').'", {
|
|
|
|
op: "save_note",
|
2023-09-11 16:16:52 +02:00
|
|
|
note: $("#note_" + id).val(),
|
|
|
|
id: id
|
2023-05-19 17:15:30 +02:00
|
|
|
}, function() {
|
2024-04-23 17:14:56 +02:00
|
|
|
renderMessages();
|
2023-09-11 16:16:52 +02:00
|
|
|
$("#note_" + id).parent().parent().parent().find(".save-nota").removeClass("btn-success");
|
|
|
|
$("#note_" + id).parent().parent().parent().find(".save-nota").addClass("btn-default");
|
2019-07-30 16:50:10 +02:00
|
|
|
});
|
2023-09-11 16:16:52 +02:00
|
|
|
}
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
$(".checkbox").click(function(){
|
|
|
|
if($(this).is(":checked")){
|
|
|
|
$.post("'.$checklist_module->fileurl('ajax.php').'", {
|
|
|
|
op: "save_checkbox",
|
|
|
|
id: $(this).attr("data-id"),
|
2023-05-05 17:23:35 +02:00
|
|
|
},function(result){
|
|
|
|
reload();
|
2019-07-30 16:50:10 +02:00
|
|
|
});
|
|
|
|
|
2023-05-05 17:23:35 +02:00
|
|
|
$(this).parent().parent().find(".text").css("text-decoration", "line-through");
|
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
parent = $(this).attr("data-id");
|
|
|
|
$("tr.sonof_"+parent).find("input[type=checkbox]").each(function(){
|
|
|
|
if(!$(this).is(":checked")){
|
|
|
|
$(this).click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
$.post("'.$checklist_module->fileurl('ajax.php').'", {
|
|
|
|
op: "remove_checkbox",
|
|
|
|
id: $(this).attr("data-id"),
|
2023-05-05 17:23:35 +02:00
|
|
|
},function(result){
|
|
|
|
reload();
|
2023-02-27 11:14:58 +01:00
|
|
|
});
|
|
|
|
|
2023-05-05 17:23:35 +02:00
|
|
|
$(this).parent().parent().find(".text").css("text-decoration", "none");
|
|
|
|
|
2023-02-27 11:14:58 +01:00
|
|
|
parent = $(this).attr("data-id");
|
|
|
|
$("tr.sonof_"+parent).find("input[type=checkbox]").each(function(){
|
|
|
|
if($(this).is(":checked")){
|
|
|
|
$(this).click();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
function delete_check(id){
|
|
|
|
if(confirm("Eliminare questa checklist?")){
|
|
|
|
$.post("'.$checklist_module->fileurl('ajax.php').'", {
|
|
|
|
op: "delete_check",
|
|
|
|
id: id,
|
2024-04-10 17:15:20 +02:00
|
|
|
id_module: globals.id_module,
|
|
|
|
id_record: id,
|
2023-02-27 11:14:58 +01:00
|
|
|
}, function(){
|
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function edit_check(id){
|
|
|
|
launch_modal("Modifica checklist", "'.$checklist_module->fileurl('components/edit-check.php').'?id_record="+id, 1);
|
|
|
|
}
|
|
|
|
|
2023-05-05 17:23:35 +02:00
|
|
|
function reload(){
|
|
|
|
$("#loading_'.$checks_id.'").removeClass("hide");
|
|
|
|
$("#loading_'.$checks_id.'").addClass("show");
|
|
|
|
$("#'.$checks_id.'").load(globals.rootdir + "/ajax.php?op=checklists&id_module='.$id_module.'&id_record='.$id_record.'&id_plugin='.$id_plugin.'", function() {
|
|
|
|
$("#loading_'.$checks_id.'").removeClass("show");
|
|
|
|
$("#loading_'.$checks_id.'").addClass("hide");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-07-30 16:50:10 +02:00
|
|
|
</script>';
|