2017-08-04 16:28:16 +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 />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/core.php' ;
2018-10-31 16:22:19 +01:00
use Carbon\Carbon ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2018-10-31 16:22:19 +01:00
2019-10-29 16:56:35 +01:00
// Disabilitazione dei campi
$read_only = $structure -> permission == 'r' ;
2019-07-26 11:57:59 +02:00
if ( empty ( $id_record ) && ! empty ( $id_module ) && empty ( $id_plugin )) {
2020-09-23 17:53:19 +02:00
redirect ( base_path () . '/controller.php?id_module=' . $id_module );
2019-07-26 11:57:59 +02:00
} elseif ( empty ( $id_record ) && empty ( $id_module ) && empty ( $id_plugin )) {
2020-09-23 17:53:19 +02:00
redirect ( base_path () . '/index.php' );
2017-08-04 16:28:16 +02:00
}
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'top.php' );
2017-08-04 16:28:16 +02:00
2019-07-26 11:57:59 +02:00
if ( ! empty ( $id_record )) {
Util\Query :: setSegments ( false );
$query = Util\Query :: getQuery ( $structure , [
'id' => $id_record ,
]);
Util\Query :: setSegments ( true );
}
2021-03-19 18:18:16 +01:00
// Rimozione della condizione deleted_at IS NULL per visualizzare anche i record eliminati
2023-08-04 14:54:28 +02:00
if ( ! empty ( $query )) {
2024-02-29 17:42:08 +01:00
if ( preg_match ( '/[`]*([a-z0-9_]*)[`]*[\.]*([`]*deleted_at[`]* IS NULL)/si' , $query , $m )) {
$query = str_replace ([ " \n " , " \t " ], ' ' , $query );
2022-03-22 18:59:25 +01:00
$conditions_to_remove = [];
$condition = trim ( $m [ 0 ]);
2021-03-19 18:18:16 +01:00
2022-03-22 18:59:25 +01:00
if ( ! empty ( $table_name )) {
$condition = $table_name . '.' . $condition ;
}
2021-03-19 18:18:16 +01:00
2024-02-29 17:42:08 +01:00
$conditions_to_remove [] = ' AND\s*' . $condition ;
$conditions_to_remove [] = $condition . '\s*AND ' ;
2021-03-19 18:18:16 +01:00
2024-02-29 17:42:08 +01:00
foreach ( $conditions_to_remove as $condition_to_remove ) {
$query = preg_replace ( '/' . $condition_to_remove . '/si' , '' , $query );
}
2022-03-22 18:59:25 +01:00
$query = str_replace ( $condition , '' , $query );
}
2020-09-09 16:55:45 +02:00
}
2019-07-05 18:29:14 +02:00
2019-02-18 09:25:31 +01:00
$has_access = ! empty ( $query ) ? $dbo -> fetchNum ( $query ) !== 0 : true ;
2017-08-04 16:28:16 +02:00
2019-02-01 17:44:31 +01:00
if ( $has_access ) {
// Inclusione gli elementi fondamentali
2020-09-23 13:36:37 +02:00
include_once base_dir () . '/actions.php' ;
2017-08-04 16:28:16 +02:00
}
2019-02-01 17:44:31 +01:00
if ( empty ( $record ) || ! $has_access ) {
2017-08-04 16:28:16 +02:00
echo '
2019-01-05 10:37:13 +01:00
< div class = " text-center " >
< h3 class = " text-muted " > ' .
'<i class="fa fa-question-circle"></i> ' . tr ( 'Record non trovato' ) . '
< br >< br >
2019-03-21 10:41:35 +01:00
< small class = " help-block " > '.tr(' Stai cercando di accedere ad un record eliminato o non presente ').' .</ small >
2019-01-05 10:37:13 +01:00
</ h3 >
< br >
2020-09-23 17:53:19 +02:00
< a class = " btn btn-default " href = " '.base_path().'/controller.php?id_module='. $id_module .' " >
2019-01-05 10:37:13 +01:00
< i class = " fa fa-chevron-left " ></ i > '.tr(' Indietro ').'
</ a >
</ div > ' ;
2017-08-04 16:28:16 +02:00
} else {
2019-02-01 17:44:31 +01:00
// Widget in alto
echo '{( "name": "widgets", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '", "position": "top", "place": "editor" )}' ;
$advanced_sessions = setting ( 'Attiva notifica di presenza utenti sul record' );
if ( ! empty ( $advanced_sessions )) {
$dbo -> query ( 'DELETE FROM zz_semaphores WHERE id_utente=' . prepare ( Auth :: user ()[ 'id' ]) . ' AND posizione=' . prepare ( $id_module . ', ' . $id_record ));
$dbo -> query ( 'INSERT INTO zz_semaphores (id_utente, posizione, updated) VALUES (' . prepare ( Auth :: user ()[ 'id' ]) . ', ' . prepare ( $id_module . ', ' . $id_record ) . ', NOW())' );
echo '
< div class = " box box-warning box-solid text-center info-active hide " >
< div class = " box-header with-border " >
< h3 class = " box-title " >< i class = " fa fa-warning " ></ i > '.tr(' Attenzione ! ').' </ h3 >
</ div >
< div class = " box-body " >
2024-02-22 15:58:03 +01:00
< p > '.tr(' I seguenti utenti stanno consultando questa scheda ').' :</ p >
2019-02-01 17:44:31 +01:00
< ul class = " list " >
</ ul >
2024-02-22 15:58:03 +01:00
< p > '.tr(' Prestare attenzione prima di effettuare modifiche , poiché queste potrebbero essere perse a causa di una sovrascrittura delle informazioni ').' .</ p >
2019-02-01 17:44:31 +01:00
</ div >
</ div > ' ;
}
2017-08-04 16:28:16 +02:00
echo '
2024-05-23 18:39:25 +02:00
< section class = " content-header " >
< div class = " container-fluid " >
< div class = " row mb-2 " >
< div class = " col-sm-6 " >
< h1 >
< i class = " '. $structure['icon'] .' " ></ i > '.$structure->getTranslation(' title ' );
2020-07-21 08:31:44 +02:00
// Pulsante "Aggiungi" solo se il modulo è di tipo "table" e se esiste il template per la popup
if ( $structure -> hasAddFile () && $structure -> permission == 'rw' ) {
2017-08-04 16:28:16 +02:00
echo '
2024-05-16 18:02:50 +02:00
< button type = " button " class = " btn btn-primary " data - widget = " modal " data - title = " '.tr('Aggiungi').'... " data - href = " add.php?id_module='. $id_module .'&id_plugin='. $id_plugin .' " >< i class = " fa fa-plus " ></ i ></ button > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
2024-05-23 18:39:25 +02:00
</ h1 >
</ div >
2020-07-21 08:31:44 +02:00
2024-05-23 18:39:25 +02:00
< div class = " col-sm-6 " >
< ol class = " breadcrumb float-sm-right " >
< li class = " breadcrumb-item " >< a href = " '. $rootdir .'/ " > Home </ a ></ li >
< li class = " breadcrumb-item " >< a href = " '. $rootdir .'/controller.php?id_module='. $id_module .' " > '.$structure->getTranslation(' title ').' </ a ></ li >
</ ol >
</ div >
</ div >
</ section >
2017-08-04 16:28:16 +02:00
2024-05-23 18:39:25 +02:00
< div class = " tab-content " >
< div id = " tab_0 " class = " tab-pane active nav-item " > ' ;
2017-08-04 16:28:16 +02:00
2019-07-08 12:25:51 +02:00
if ( ! empty ( $record [ 'deleted_at' ])) {
2019-07-23 16:12:46 +02:00
$operation = $dbo -> fetchOne ( " SELECT zz_operations.created_at, username FROM zz_operations INNER JOIN zz_users ON zz_operations.id_utente = zz_users.id WHERE op='delete' AND id_module= " . prepare ( $id_module ) . ' AND id_record=' . prepare ( $id_record ) . ' ORDER BY zz_operations.created_at DESC' );
2020-03-18 22:31:01 +01:00
$info = tr ( 'Il record è stato eliminato il <b>_DATE_</b> da <b>_USER_</b>' , [
2020-03-18 22:37:08 +01:00
'_DATE_' => (( $operation [ 'created_at' ]) ? Translator :: timestampToLocale ( $operation [ 'created_at' ]) : Translator :: timestampToLocale ( $record [ 'deleted_at' ])),
2020-03-18 22:31:01 +01:00
'_USER_' => (( ! empty ( $operation [ 'username' ])) ? $operation [ 'username' ] : 'N.D.' ),
]) . '. ' ;
2019-07-05 18:29:14 +02:00
echo '
2019-11-23 07:26:13 +01:00
< div class = " alert alert-warning " >
2019-07-23 16:12:46 +02:00
< div class = " row " >
< div class = " col-md-8 " >
2019-11-23 07:26:13 +01:00
< i class = " fa fa-warning " ></ i > '.$info.'
2019-07-23 12:13:58 +02:00
</ div >
</ div >
2019-07-05 18:29:14 +02:00
</ div >
2020-02-24 15:37:27 +01:00
2019-07-05 18:29:14 +02:00
< script >
2020-02-24 15:37:27 +01:00
$ ( document ) . ready ( function (){
2021-03-19 18:18:16 +01:00
$ ( " #restore, #restore-close " ) . click ( function (){
2019-07-05 18:29:14 +02:00
$ ( " input[name=op] " ) . attr ( " value " , " restore " );
$ ( " #submit " ) . trigger ( " click " );
})
});
</ script > ' ;
}
2018-02-22 11:07:52 +01:00
// Pulsanti di default
2024-05-16 18:02:50 +02:00
echo '
< div id = " pulsanti " >
< a class = " btn btn-default " id = " back " href = " '.base_path().'/controller.php?id_module='. $id_module .' " >
< i class = " fa fa-chevron-left " ></ i > '.tr("Torna all' elenco " ).'
</ a >
2018-02-22 10:32:51 +01:00
2024-05-16 18:02:50 +02:00
< div class = " float-right d-none d-sm-inline " >
{( " name " : " button " , " type " : " print " , " id_module " : " '. $id_module .' " , " id_plugin " : " '. $id_plugin .' " , " id_record " : " '. $id_record .' " )}
2018-02-22 10:32:51 +01:00
2024-05-16 18:02:50 +02:00
{( " name " : " button " , " type " : " email " , " id_module " : " '. $id_module .' " , " id_plugin " : " '. $id_plugin .' " , " id_record " : " '. $id_record .' " )} ' ;
2021-12-30 10:59:21 +01:00
2024-06-11 16:58:27 +02:00
if ( Module :: where ( 'name' , 'Account SMS' ) -> first () -> id ) {
2024-05-21 16:26:19 +02:00
echo '
2024-05-16 18:02:50 +02:00
{( " name " : " button " , " type " : " sms " , " id_module " : " '. $id_module .' " , " id_plugin " : " '. $id_plugin .' " , " id_record " : " '. $id_record .' " )} ' ;
2023-08-04 14:54:28 +02:00
}
2021-12-30 10:59:21 +01:00
2023-08-04 14:54:28 +02:00
echo '
2018-02-22 10:32:51 +01:00
2024-05-16 18:02:50 +02:00
< div class = " btn-group " id = " save-buttons " >
< button type = " button " class = " btn btn-success " id = " '.(!empty( $record['deleted_at'] ) ? 'restore' : 'save').' " >
< i class = " fa fa-'.(!empty( $record['deleted_at'] ) ? 'undo' : 'check').' " ></ i > '.(!empty($record[' deleted_at ']) ? tr(' Salva e ripristina ') : tr(' Salva ')).'
</ button >
< button type = " button " class = " btn btn-success dropdown-toggle dropdown-icon " data - toggle = " dropdown " aria - expanded = " false " >
< span class = " sr-only " > Toggle Dropdown </ span >
</ button >
< div class = " dropdown-menu " role = " menu " >
< a class = " dropdown-item " href = " # " id = " '.(!empty( $record['deleted_at'] ) ? 'restore' : 'save').'-close " >
< i class = " fa fa-'.(!empty( $record['deleted_at'] ) ? 'undo' : 'check-square-o').' " ></ i >
'.(!empty($record[' deleted_at ']) ? tr(' Ripristina e chiudi ') : tr(' Salva e chiudi ')).'
2021-03-15 11:10:46 +01:00
</ a >
</ div >
2018-02-22 10:32:51 +01:00
</ div >
</ div >
2024-05-16 18:02:50 +02:00
</ div >
2018-02-22 10:32:51 +01:00
2024-05-16 18:02:50 +02:00
< script >
$ ( document ) . ready ( function (){
var form = $ ( " #module-edit " ) . find ( " form " ) . first ();
2020-02-24 15:37:27 +01:00
2024-05-16 18:02:50 +02:00
// Aggiunta del submit
form . prepend ( \ ' < button type = " submit " id = " submit " class = " hide " ></ button > \ ' );
2021-03-15 11:10:46 +01:00
2024-05-16 18:02:50 +02:00
$ ( " #save " ) . click ( function (){
//submitAjax(form);
2018-02-23 09:49:31 +01:00
2024-05-16 18:02:50 +02:00
$ ( " #submit " ) . trigger ( " click " );
});
2018-02-23 09:49:31 +01:00
2024-05-16 18:02:50 +02:00
$ ( " #save-close " ) . on ( " click " , function (){
form . find ( " [name=backto] " ) . val ( " record-list " );
$ ( " #submit " ) . trigger ( " click " );
2018-02-22 10:32:51 +01:00
});
2024-05-16 18:02:50 +02:00
});
</ script >
2018-02-22 10:32:51 +01:00
2024-05-16 18:02:50 +02:00
< div class = " clearfix " ></ div >
< br > ' ;
2018-02-22 10:32:51 +01:00
2018-02-22 11:07:52 +01:00
// Pulsanti personalizzati
2018-09-19 10:44:32 +02:00
$buttons = $structure -> filepath ( 'buttons.php' );
2018-02-22 11:07:52 +01:00
if ( ! empty ( $buttons )) {
2018-07-19 12:47:28 +02:00
ob_start ();
include $buttons ;
$buttons = ob_get_clean ();
2018-02-22 11:07:52 +01:00
echo '
2024-05-16 18:02:50 +02:00
< div class = " float-right d-none d-sm-inline " id = " pulsanti-modulo " >
'.$buttons.'
</ div >
2018-02-22 11:07:52 +01:00
2024-05-16 18:02:50 +02:00
< div class = " clearfix " ></ div >
< br > ' ;
2024-05-09 10:29:53 +02:00
// Eventuale header personalizzato
$header = $structure -> filepath ( 'header.php' );
if ( $header ) {
include_once $header ;
}
2018-02-22 11:07:52 +01:00
}
// Contenuti del modulo
echo '
2024-05-16 18:02:50 +02:00
< div id = " module-edit " > ' ;
2018-02-22 11:07:52 +01:00
2021-04-26 09:53:41 +02:00
$path = $structure -> getEditFile ();
if ( ! empty ( $path )) {
include $path ;
}
2017-08-04 16:28:16 +02:00
echo '
2024-05-16 18:02:50 +02:00
</ div >
</ div > ' ;
2017-08-04 16:28:16 +02:00
2018-02-10 17:24:16 +01:00
// Campi personalizzati
echo '
2024-05-16 18:02:50 +02:00
< div class = " hide " id = " custom_fields_top-edit_'. $id_module .'-'. $id_plugin .' " >
{( " name " : " custom_fields " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " , " position " : " top " )}
</ div >
2018-02-10 17:24:16 +01:00
2024-05-16 18:02:50 +02:00
< div class = " hide " id = " custom_fields_bottom-edit_'. $id_module .'-'. $id_plugin .' " >
{( " name " : " custom_fields " , " id_module " : " '. $id_module .' " , " id_record " : " '. $id_record .' " )}
</ div >
2018-02-10 17:24:16 +01:00
2024-05-16 18:02:50 +02:00
< script >
$ ( document ) . ready ( function (){
let form = $ ( " #edit-form " ) . first ();
2020-02-24 15:37:27 +01:00
2024-05-16 18:02:50 +02:00
// Ultima sezione/campo del form
let last = form . find ( " .panel " ) . last ();
2018-09-24 10:51:48 +02:00
2024-05-16 18:02:50 +02:00
if ( ! last . length ) {
last = form . find ( " .box " ) . last ();
}
2018-09-24 10:51:48 +02:00
2024-05-16 18:02:50 +02:00
if ( ! last . length ) {
2024-06-21 15:41:39 +02:00
last = form . find ( " .row " ) . last ();
2024-05-16 18:02:50 +02:00
}
2020-02-24 15:37:27 +01:00
2024-05-16 18:02:50 +02:00
// Campi a inizio form
aggiungiContenuto ( form , " #custom_fields_top-edit_'. $id_module .'-'. $id_plugin .' " , {}, true );
2021-02-23 15:47:25 +01:00
2024-05-16 18:02:50 +02:00
// Campi a fine form
aggiungiContenuto ( last , " #custom_fields_bottom-edit_'. $id_module .'-'. $id_plugin .' " , {});
});
</ script > ' ;
2018-02-10 17:24:16 +01:00
2020-09-24 09:53:53 +02:00
if ( $structure -> permission != '-' && $structure -> use_notes && $user -> gruppo != 'Clienti' ) {
2019-07-26 11:57:59 +02:00
echo '
2024-05-16 18:02:50 +02:00
< div id = " tab_note " class = " tab-pane " > ' ;
2019-07-26 11:57:59 +02:00
2020-09-23 13:36:37 +02:00
include base_dir () . '/plugins/notes.php' ;
2019-07-26 11:57:59 +02:00
2019-07-30 16:50:10 +02:00
echo '
2024-05-16 18:02:50 +02:00
</ div > ' ;
2019-07-30 16:50:10 +02:00
}
2019-07-26 11:57:59 +02:00
2019-07-30 16:50:10 +02:00
if ( $structure -> permission != '-' && $structure -> use_checklists ) {
echo '
2024-05-16 18:02:50 +02:00
< div id = " tab_checks " class = " tab-pane " > ' ;
2019-07-26 11:57:59 +02:00
2020-09-23 13:36:37 +02:00
include base_dir () . '/plugins/checks.php' ;
2019-07-26 11:57:59 +02:00
echo '
2024-05-16 18:02:50 +02:00
</ div > ' ;
2019-07-26 11:57:59 +02:00
}
2018-07-13 20:17:20 +02:00
// Informazioni sulle operazioni
if ( Auth :: admin ()) {
2018-10-31 16:22:19 +01:00
echo '
2024-05-21 17:43:53 +02:00
< div id = " tab_info " class = " tab-pane " >
< div class = " timeline " > ' ;
2018-07-13 20:17:20 +02:00
2024-03-05 16:01:45 +01:00
$operations = $dbo -> fetchArray ( 'SELECT `zz_operations`.*, `zz_users`.`username` FROM `zz_operations` LEFT JOIN `zz_users` ON `zz_operations`.`id_utente` = `zz_users`.`id` WHERE id_module = ' . prepare ( $id_module ) . ' AND id_record = ' . prepare ( $id_record ) . ' ORDER BY `created_at` DESC LIMIT 200' );
2018-10-30 20:33:28 +01:00
2018-10-31 16:22:19 +01:00
if ( ! empty ( $operations )) {
2018-10-30 20:33:28 +01:00
foreach ( $operations as $operation ) {
$description = $operation [ 'op' ];
$icon = 'pencil-square-o' ;
2024-05-21 17:43:53 +02:00
$color = 'warning' ;
2018-10-30 20:33:28 +01:00
switch ( $operation [ 'op' ]) {
case 'add' :
$description = tr ( 'Creazione' );
$icon = 'plus' ;
$color = 'success' ;
break ;
case 'update' :
$description = tr ( 'Modifica' );
$icon = 'pencil' ;
$color = 'info' ;
break ;
case 'delete' :
$description = tr ( 'Eliminazione' );
$icon = 'times' ;
$color = 'danger' ;
break ;
2020-02-14 12:23:50 +01:00
2020-02-13 03:09:49 +01:00
case 'copy' :
$description = tr ( 'Duplicato' );
$icon = 'clone' ;
$color = 'info' ;
break ;
2018-10-30 20:33:28 +01:00
}
echo '
2024-05-21 17:43:53 +02:00
< div >
< i class = " fa fa-'. $icon .' bg-'. $color .' " ></ i >
< div class = " timeline-item " >
< span class = " time " >< i class = " fa fa-clock-o " ></ i > '.Carbon::parse($operation[' created_at '])->diffForHumans().' </ small ></ span >
< h4 class = " timeline-header " > '.$description.' </ h4 >
2024-05-16 18:02:50 +02:00
< div class = " timeline-body " >
2024-05-21 17:43:53 +02:00
< span class = " badge badge-default " >< i class = " fa fa-user " ></ i > '.$operation[' username '].'
2018-07-14 10:59:14 +02:00
</ div >
2024-05-16 18:02:50 +02:00
</ div >
2024-05-21 17:43:53 +02:00
</ div > ' ;
2018-10-31 16:22:19 +01:00
}
2024-05-23 11:36:25 +02:00
echo '
2024-05-21 17:43:53 +02:00
< div >
< i class = " fa fa-clock-o bg-gray " ></ i >
</ div >
</ div > ' ;
2018-10-31 16:22:19 +01:00
} else {
echo '
2024-05-16 18:02:50 +02:00
< div class = " alert alert-info " >
< i class = " fa fa-info-circle " ></ i >
< b > '.tr(' Informazione : ').' </ b > '.tr(' Nessun log disponibile per questa scheda ').' .
</ div > ' ;
2018-10-30 20:33:28 +01:00
}
2019-07-26 11:57:59 +02:00
2018-10-31 16:22:19 +01:00
echo '
2024-05-16 18:02:50 +02:00
</ div > ' ;
2018-07-13 20:17:20 +02:00
}
// Plugin
2018-07-18 15:20:10 +02:00
$module_record = $record ;
2017-08-04 16:28:16 +02:00
foreach ( $plugins as $plugin ) {
2018-07-18 15:20:10 +02:00
$record = $module_record ;
2017-08-04 16:28:16 +02:00
echo '
2024-05-16 18:02:50 +02:00
< div id = " tab_'. $plugin['id'] .' " class = " tab-pane " > ' ;
2017-08-04 16:28:16 +02:00
$id_plugin = $plugin [ 'id' ];
2020-09-23 13:36:37 +02:00
include base_dir () . '/include/manager.php' ;
2017-08-04 16:28:16 +02:00
echo '
2024-05-16 18:02:50 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2018-07-18 15:20:10 +02:00
$record = $module_record ;
2017-08-04 16:28:16 +02:00
echo '
2024-05-23 18:39:25 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
2024-04-11 12:26:12 +02:00
redirectOperation ( $id_module , ! empty ( $id_parent ) ? $id_parent : $id_record );
2017-08-04 16:28:16 +02:00
2018-02-22 12:35:22 +01:00
// Widget in basso
echo '{( "name": "widgets", "id_module": "' . $id_module . '", "id_record": "' . $id_record . '", "position": "right", "place": "editor" )}' ;
2019-01-05 10:37:13 +01:00
if ( ! empty ( $record )) {
echo '
2024-05-16 18:02:50 +02:00
< hr >
< a class = " btn btn-default " href = " '.base_path().'/controller.php?id_module='. $id_module .' " >
< i class = " fa fa-chevron-left " ></ i > '.tr(' Indietro ').'
</ a > ' ;
2019-01-05 10:37:13 +01:00
}
2017-08-04 16:28:16 +02:00
echo '
2018-07-02 15:41:38 +02:00
< script > ' ;
2017-08-04 16:28:16 +02:00
// Se l'utente ha i permessi in sola lettura per il modulo, converto tutti i campi di testo in span
2018-07-09 16:12:27 +02:00
if ( $read_only || ! empty ( $block_edit )) {
$not = $read_only ? '' : '.not(".unblockable")' ;
2018-07-04 12:57:53 +02:00
echo '
$ ( document ) . ready ( function (){
$ ( " input, textarea, select " , " section.content " ) '.$not.' . attr ( " readonly " , " true " );
2020-08-07 12:28:05 +02:00
$ ( " select, input[type=checkbox] " , " section.content " ) '.$not.' . prop ( " disabled " , true );
2024-05-16 18:02:50 +02:00
$ ( " .checkbox-buttons badge " , " section.content " ) '.$not.' . addClass ( " disabled " );
2020-08-07 12:28:05 +02:00
' ;
2018-07-09 16:12:27 +02:00
2020-09-24 09:53:53 +02:00
// Nascondo il plugin Note interne ai clienti
2020-09-24 09:25:44 +02:00
if ( $user -> gruppo == 'Clienti' ) {
2020-09-22 16:31:33 +02:00
echo '
$ ( " #link-tab_note " ) . hide (); ' ;
}
2018-07-09 16:12:27 +02:00
if ( $read_only ) {
echo '
$ ( " a.btn, button, input[type=button], input[type=submit] " , " section.content " ) . hide ();
2021-12-09 09:43:10 +01:00
$ ( " a.btn-info, button.btn-info, input[type=button].btn-info, #back " , " section.content " ) . show (); ' ;
2018-07-09 16:12:27 +02:00
}
2018-07-04 12:57:53 +02:00
2018-07-09 16:12:27 +02:00
echo '
2018-07-04 12:57:53 +02:00
}); ' ;
}
?>
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
var content_was_modified = false ;
2021-07-30 16:33:23 +02:00
// Controllo se digito qualche valore o cambio qualche select
$ ( " .content input, .content textarea, .content select " ) . bind ( " change paste keyup " , function ( event ) {
2020-08-07 12:28:05 +02:00
if ( event . keyCode >= 32 ) {
2018-07-02 15:41:38 +02:00
content_was_modified = true ;
}
});
2021-07-30 16:33:23 +02:00
$ ( " .content .superselect, .content .superselectajax " ) . on ( " change " , function ( e ) {
2019-11-23 07:26:13 +01:00
content_was_modified = true ;
});
2021-07-30 16:33:23 +02:00
// Tolgo il controllo se sto salvando
$ ( " .content .btn-success, .content button[type=submit] " ) . bind ( " click " , function () {
2018-07-02 15:41:38 +02:00
content_was_modified = false ;
});
2018-08-10 17:14:09 +02:00
2020-08-07 12:28:05 +02:00
$ ( " form " ) . bind ( " submit " , function () {
2018-07-31 19:20:19 +02:00
content_was_modified = false ;
2020-08-07 12:28:05 +02:00
});
2018-07-02 15:41:38 +02:00
2018-07-26 13:10:16 +02:00
// questo controllo blocca il modulo vendita al banco, dopo la lettura con barcode, appare il messaggio di conferma
2023-03-10 11:07:55 +01:00
window . addEventListener ( " beforeunload " , function ( e ) {
2018-07-02 15:41:38 +02:00
if ( content_was_modified ) {
2018-07-26 13:10:16 +02:00
var dialogText = " Uscire senza salvare? " ;
e . returnValue = dialogText ;
return dialogText ;
2018-07-02 15:41:38 +02:00
}
2023-03-10 11:07:55 +01:00
});
2018-08-10 17:14:09 +02:00
2017-08-04 16:28:16 +02:00
< ? php
2018-08-28 15:54:29 +02:00
if ( ! empty ( $advanced_sessions )) {
2018-07-07 13:56:22 +02:00
?>
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
function getActiveUsers (){
2020-09-23 17:53:19 +02:00
$ . getJSON ( '<?php echo base_path(); ?>/ajax.php?op=active_users' , {
2018-07-02 15:41:38 +02:00
id_module : < ? php echo $id_module ; ?> ,
id_record : < ? php echo $id_record ; ?>
},
function ( data ) {
if ( data . length != 0 ) {
$ ( " .info-active " ) . removeClass ( " hide " );
$ ( " .info-active .list " ) . html ( " " );
$ . each ( data , function ( key , val ) {
$ ( " .info-active .list " ) . append ( " <li> " + val . username + " </li> " );
});
}
else $ ( " .info-active " ) . addClass ( " hide " );
});
}
2017-08-04 16:28:16 +02:00
2018-07-02 15:41:38 +02:00
getActiveUsers ();
2017-08-04 16:28:16 +02:00
2018-08-28 15:54:29 +02:00
setInterval ( getActiveUsers , < ? php echo setting ( 'Timeout notifica di presenza (minuti)' ) * 60 * 1000 ; ?> );
2017-08-04 16:28:16 +02:00
< ? php
2018-07-07 13:56:22 +02:00
}
2017-08-04 16:28:16 +02:00
?>
2018-07-02 15:41:38 +02:00
</ script >
2017-08-04 16:28:16 +02:00
< ? php
2018-06-26 09:41:43 +02:00
include_once App :: filepath ( 'include|custom|' , 'bottom.php' );