2019-07-29 13:16:55 +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-29 13:16:55 +02:00
include_once __DIR__ . '/../../core.php' ;
echo '
< form action = " " method = " post " id = " edit-form " >
< input type = " hidden " name = " op " value = " update " >
< input type = " hidden " name = " backto " value = " record-edit " >
<!-- DATI -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " > '.tr(' Dati ').' </ h3 >
2019-07-29 13:16:55 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2019-07-29 13:16:55 +02:00
< div class = " row " >
< div class = " col-md-6 " >
2024-04-23 15:25:32 +02:00
{[ " type " : " text " , " label " : " '.tr('Nome').' " , " name " : " name " , " value " : " $name $ " , " required " : 1 ]}
2019-07-29 13:16:55 +02:00
</ div >
< div class = " col-md-3 " >
2024-03-22 15:52:24 +01:00
{[ " type " : " select " , " label " : " '.tr('Modulo del template').' " , " name " : " module " , " values " : " query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = '.prepare(Models \ Locale::getDefault()->id).') WHERE `enabled` = 1 " , " value " : " '. $record->id_module .' " , " disabled " : " '.!empty( $record->id_plugin ).' " ]}
2019-07-29 13:16:55 +02:00
</ div >
2020-07-31 14:25:50 +02:00
2019-07-29 13:16:55 +02:00
< div class = " col-md-3 " >
2024-04-18 17:44:05 +02:00
{[ " type " : " select " , " label " : " '.tr('Plugin del template').' " , " name " : " plugin " , " values " : " query=SELECT `zz_plugins`.`id`, `zz_plugins_lang`.`title` AS descrizione, `zz_modules_lang`.`title` AS optgroup FROM zz_plugins INNER JOIN `zz_modules` ON `zz_plugins`.`idmodule_to` = `zz_modules`.`id` LEFT JOIN `zz_modules_lang` ON (`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = '.prepare(Models \ Locale::getDefault()->id).') LEFT JOIN `zz_plugins_lang` ON (`zz_plugins`.`id` = `zz_plugins_lang`.`id_record` AND `zz_plugins_lang`.`id_lang` = '.prepare(Models \ Locale::getDefault()->id).') WHERE `zz_plugins`.`enabled` = 1 " , " value " : " '. $record->id_plugin .' " , " disabled " : " '.!empty( $record->id_module ).' " ]}
2019-07-29 13:16:55 +02:00
</ div >
</ div >
</ div >
</ div >
</ form >
< script >
$ ( document ) . ready ( function () {
$ ( " #module " ) . change ( function () {
if ( $ ( this ) . val ()){
2019-07-29 17:42:24 +02:00
$ ( " #plugin " ) . val ( " " ) . attr ( " disabled " , true );
2019-07-29 13:16:55 +02:00
} else {
2019-07-29 17:42:24 +02:00
$ ( " #plugin " ) . val ( " " ) . attr ( " disabled " , false );
2019-07-29 13:16:55 +02:00
}
});
2020-07-31 14:25:50 +02:00
2019-07-29 13:16:55 +02:00
$ ( " #plugin " ) . change ( function () {
if ( $ ( this ) . val ()){
2019-07-29 17:42:24 +02:00
$ ( " #module " ) . val ( " " ) . attr ( " disabled " , true );
2019-07-29 13:16:55 +02:00
} else {
2019-07-29 17:42:24 +02:00
$ ( " #module " ) . val ( " " ) . attr ( " disabled " , false );
2019-07-29 13:16:55 +02:00
}
});
});
</ script > ' ;
2023-03-13 16:22:50 +01:00
$checks = $record -> mainChecks ();
2019-07-29 13:16:55 +02:00
$list = [];
foreach ( $checks as $check ) {
$list [] = [
'id' => $check -> id ,
'text' => $check -> content ,
];
}
echo '
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
2024-05-17 12:11:00 +02:00
< div class = " card-header " >
2024-05-16 18:02:50 +02:00
< h3 class = " card-title " > '.tr(' Checklist ').' </ h3 >
2019-07-29 13:16:55 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2019-07-29 13:16:55 +02:00
< form action = " " method = " post " id = " checklist-form " class = " row " >
< input type = " hidden " name = " op " value = " add_item " >
< input type = " hidden " name = " backto " value = " record-edit " >
2020-07-31 14:25:50 +02:00
2023-07-21 17:19:43 +02:00
< div class = " col-md-7 " >
' . input ([
2024-03-22 15:52:24 +01:00
'type' => 'ckeditor' ,
'label' => tr ( 'Contenuto' ),
'name' => 'content' ,
'required' => 1 ,
'value' => '' ,
]) . '
2019-07-29 13:16:55 +02:00
</ div >
2020-07-31 14:25:50 +02:00
2023-07-21 17:19:43 +02:00
< div class = " col-md-5 text-center " >
{[ " type " : " select " , " label " : " '.tr('Genitore').' " , " name " : " parent " , " class " : " unblockable " , " values " : '.json_encode($list).' ]}
< br >
{[ " type " : " checkbox " , " label " : " '.tr('Utilizza come titolo').' " , " name " : " is_titolo " ]}
< br >< br >
< button type = " submit " class = " btn btn-lg btn-success " >
2019-07-29 13:16:55 +02:00
< i class = " fa fa-upload " ></ i > '.tr(' Crea ').'
</ button >
</ div >
</ form >
< hr >
2020-07-31 14:25:50 +02:00
2019-07-30 16:50:10 +02:00
< ul class = " todo-list checklist " > ' ;
2019-07-29 13:16:55 +02:00
2023-03-13 16:22:50 +01:00
echo " <table class='table'>
< tbody class = 'sort' data - sonof = '0' > " ;
foreach ( $checks as $check ) {
echo renderChecklistInserimento ( $check );
}
2023-08-04 14:54:28 +02:00
echo ' </ tbody >
</ table > ' ;
2019-07-29 13:16:55 +02:00
2023-03-13 16:22:50 +01:00
echo '
2019-07-29 13:16:55 +02:00
</ ul >
</ div >
</ div > ' ;
echo '
< script >
$ ( document ) . ready ( function () {
2019-07-30 16:50:10 +02:00
$ ( " .checklist " ) . sortable ({
placeholder : " sort-highlight " ,
handle : " .handle " ,
forcePlaceholderSize : true ,
zIndex : 999999 ,
update : function ( event , ui ) {
var order = [];
2020-07-31 14:25:50 +02:00
$ ( " .checklist > li " ) . each ( function () {
2019-07-30 16:50:10 +02:00
order . push ( $ ( this ) . data ( " id " ));
});
$ . post ( globals . rootdir + " /actions.php " , {
id_module : globals . id_module ,
id_record : globals . id_record ,
op : " update_position " ,
order : order . join ( " , " ),
});
}
});
2019-07-29 13:16:55 +02:00
$ ( " .check-delete " ) . click ( function ( event ){
var li = $ ( this ) . closest ( " li " );
var id = li . attr ( " id " ) . replace ( " check_ " , " " );
2020-07-31 14:25:50 +02:00
2019-07-29 13:16:55 +02:00
$ . ajax ({
url : globals . rootdir + " /actions.php " ,
cache : false ,
type : " POST " ,
data : {
id_module : globals . id_module ,
op : " delete_item " ,
check_id : id ,
},
success : function () {
location . reload ();
}
});
2020-07-31 14:25:50 +02:00
event . stopPropagation ();
2019-07-29 13:16:55 +02:00
});
});
</ script > ' ;
echo '
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > '.tr(' Elimina ').'
2023-03-13 16:22:50 +01:00
</ a >
< script >
sortable ( " .sort " , {
axis : " y " ,
handle : " .handle " ,
cursor : " move " ,
dropOnEmpty : true ,
scroll : true ,
});
sortable_table = sortable ( " .sort " ) . length ;
for ( i = 0 ; i < sortable_table ; i ++ ){
sortable ( " .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 ( " , " ),
main_check : 1 ,
});
});
}
function delete_check ( id ){
if ( confirm ( " Eliminare questa checklist? " )){
$ . post ( " '. $checklist_module->fileurl ('ajax.php').' " , {
op : " delete_check " ,
id : id ,
main_check : 1 ,
2024-04-10 17:15:20 +02:00
id_module : globals . id_module ,
id_record : id ,
2023-03-13 16:22:50 +01:00
}, function (){
location . reload ();
});
}
}
function edit_check ( id ){
launch_modal ( " Modifica checklist " , " '. $checklist_module->fileurl ('components/edit-check.php').'?id_record= " + id + " &main_check=1 " , 1 );
}
2023-08-04 14:54:28 +02:00
</ script > ' ;