2018-02-09 15:43:51 +01: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 />.
*/
2018-02-09 15:43:51 +01:00
2019-11-08 15:09:05 +01:00
include_once __DIR__ . '/../../core.php' ;
2018-06-18 15:56:00 +02:00
2022-11-30 17:02:07 +01:00
use Models\OperationLog ;
2018-12-29 12:03:22 +01:00
use Modules\Anagrafiche\Anagrafica ;
2023-08-04 14:54:28 +02:00
use Modules\Emails\Mail ;
use Modules\Emails\Template ;
2018-09-27 17:27:39 +02:00
use Modules\Fatture\Fattura ;
use Modules\Fatture\Tipo ;
2020-03-09 16:36:35 +01:00
use Modules\Interventi\Intervento ;
use Modules\Interventi\Stato ;
2018-12-29 12:03:22 +01:00
use Util\Zip ;
2018-09-19 16:51:37 +02:00
2018-09-27 17:27:39 +02:00
// Segmenti
$id_fatture = Modules :: get ( 'Fatture di vendita' )[ 'id' ];
if ( ! isset ( $_SESSION [ 'module_' . $id_fatture ][ 'id_segment' ])) {
$segments = Modules :: getSegments ( $id_fatture );
$_SESSION [ 'module_' . $id_fatture ][ 'id_segment' ] = isset ( $segments [ 0 ][ 'id' ]) ? $segments [ 0 ][ 'id' ] : null ;
}
$id_segment = $_SESSION [ 'module_' . $id_fatture ][ 'id_segment' ];
2021-09-03 17:57:49 +02:00
$idtipodocumento = $dbo -> selectOne ( 'co_tipidocumento' , [ 'id' ], [
'predefined' => 1 ,
'dir' => 'entrata' ,
])[ 'id' ];
2018-02-09 15:43:51 +01:00
switch ( post ( 'op' )) {
case 'export-bulk' :
2020-09-23 13:36:37 +02:00
$dir = base_dir () . '/files/export_interventi/' ;
2018-02-09 15:43:51 +01:00
directory ( $dir . 'tmp/' );
// Rimozione dei contenuti precedenti
$files = glob ( $dir . '/*.zip' );
foreach ( $files as $file ) {
delete ( $file );
}
2018-07-18 15:20:10 +02:00
// Selezione degli interventi da stampare
$interventi = $dbo -> fetchArray ( 'SELECT in_interventi.id, in_interventi.codice, data_richiesta, ragione_sociale FROM in_interventi INNER JOIN an_anagrafiche ON in_interventi.idanagrafica=an_anagrafiche.idanagrafica WHERE in_interventi.id IN(' . implode ( ',' , $id_records ) . ')' );
2018-02-09 15:43:51 +01:00
2018-07-18 15:20:10 +02:00
if ( ! empty ( $interventi )) {
foreach ( $interventi as $r ) {
2018-09-26 10:49:38 +02:00
$print = Prints :: getModulePredefinedPrint ( $id_module );
2018-02-18 19:53:23 +01:00
2022-02-25 16:41:05 +01:00
Prints :: render ( $print [ 'id' ], $r [ 'id' ], $dir . 'tmp/' , false , false );
2018-02-09 15:43:51 +01:00
}
$dir = slashes ( $dir );
$file = slashes ( $dir . 'interventi_' . time () . '.zip' );
// Creazione zip
if ( extension_loaded ( 'zip' )) {
2018-09-19 16:51:37 +02:00
Zip :: create ( $dir . 'tmp/' , $file );
2018-02-09 15:43:51 +01:00
// Invio al browser dello zip
download ( $file );
// Rimozione dei contenuti
delete ( $dir . 'tmp/' );
}
}
2018-03-22 15:40:20 +01:00
break ;
2018-08-31 12:33:48 +02:00
case 'crea_fattura' :
$id_documento_cliente = [];
2022-04-07 17:26:23 +02:00
$fatturati = [];
2018-08-31 12:33:48 +02:00
$n_interventi = 0 ;
2018-03-22 15:40:20 +01:00
2018-03-08 17:29:32 +01:00
$data = date ( 'Y-m-d' );
$dir = 'entrata' ;
2021-09-03 17:57:49 +02:00
$tipo_documento = Tipo :: where ( 'id' , post ( 'idtipodocumento' )) -> first ();
2018-03-08 17:29:32 +01:00
2018-09-03 16:01:05 +02:00
$id_conto = setting ( 'Conto predefinito fatture di vendita' );
2018-03-08 17:29:32 +01:00
2018-08-31 12:33:48 +02:00
$accodare = post ( 'accodare' );
2018-09-27 17:27:39 +02:00
$id_segment = post ( 'id_segment' );
2018-03-08 17:29:32 +01:00
2023-02-06 17:50:13 +01:00
$where = '' ;
// Lettura interventi non collegati a preventivi, ordini e contratti
2023-05-23 11:05:31 +02:00
if ( ! setting ( 'Permetti fatturazione delle attività collegate a contratti' )) {
$where = ' AND in_interventi.id_contratto IS NULL' ;
}
if ( ! setting ( 'Permetti fatturazione delle attività collegate a ordini' )) {
$where .= ' AND in_interventi.id_ordine IS NULL' ;
}
if ( ! setting ( 'Permetti fatturazione delle attività collegate a preventivi' )) {
$where .= ' AND in_interventi.id_preventivo IS NULL' ;
2023-02-06 17:50:13 +01:00
}
$interventi = $dbo -> fetchArray ( 'SELECT *, IFNULL((SELECT MIN(orario_inizio) FROM in_interventi_tecnici WHERE in_interventi_tecnici.idintervento = in_interventi.id), in_interventi.data_richiesta) AS data, in_statiintervento.descrizione AS stato, in_interventi.codice AS codice_intervento FROM in_interventi INNER JOIN in_statiintervento ON in_interventi.idstatointervento=in_statiintervento.idstatointervento WHERE in_statiintervento.is_completato=1 AND in_statiintervento.is_fatturabile=1 AND in_interventi.id NOT IN (SELECT idintervento FROM co_righe_documenti WHERE idintervento IS NOT NULL) AND in_interventi.id NOT IN (SELECT idintervento FROM co_promemoria WHERE idintervento IS NOT NULL) AND in_interventi.id IN (' . implode ( ',' , $id_records ) . ') ' . $where );
2018-09-24 10:51:48 +02:00
2018-08-31 12:33:48 +02:00
// Lettura righe selezionate
foreach ( $interventi as $intervento ) {
2023-08-04 14:54:28 +02:00
if ( ! empty ( $intervento [ 'idclientefinale' ])) {
2022-12-06 17:04:01 +01:00
$id_anagrafica = $intervento [ 'idclientefinale' ];
2023-08-04 14:54:28 +02:00
} else {
2022-12-06 17:04:01 +01:00
$id_anagrafica = $intervento [ 'idanagrafica' ];
}
2018-08-31 12:33:48 +02:00
$id_documento = $id_documento_cliente [ $id_anagrafica ];
2018-03-22 15:40:20 +01:00
2021-09-21 15:17:43 +02:00
$anagrafica = Anagrafica :: find ( $id_anagrafica );
$id_iva = $anagrafica -> idiva_vendite ? : setting ( 'Iva predefinita' );
2018-08-31 12:33:48 +02:00
// Se non c'è già una fattura appena creata per questo cliente, creo una fattura nuova
if ( empty ( $id_documento )) {
if ( ! empty ( $accodare )) {
2023-02-15 17:44:12 +01:00
$documento = $dbo -> fetchOne ( 'SELECT co_documenti.id FROM co_documenti INNER JOIN co_statidocumento ON co_documenti.idstatodocumento = co_statidocumento.id INNER JOIN co_tipidocumento ON co_tipidocumento.id = co_documenti.idtipodocumento INNER JOIN zz_segments ON zz_segments.id = co_documenti.id_segment WHERE co_statidocumento.descrizione = "Bozza" AND co_documenti.idanagrafica = ' . prepare ( $id_anagrafica ) . ' AND co_tipidocumento.id=' . prepare ( $tipo_documento [ 'id' ]) . ' AND co_documenti.id_segment = ' . prepare ( $id_segment ));
2018-03-22 15:40:20 +01:00
2018-08-31 12:33:48 +02:00
$id_documento = $documento [ 'id' ];
$id_documento_cliente [ $id_anagrafica ] = $id_documento ;
2018-03-22 15:40:20 +01:00
}
2018-08-31 12:33:48 +02:00
if ( empty ( $id_documento )) {
2019-01-02 14:15:16 +01:00
$fattura = Fattura :: build ( $anagrafica , $tipo_documento , $data , $id_segment );
2018-09-27 17:27:39 +02:00
$id_documento = $fattura -> id ;
2018-08-31 12:33:48 +02:00
$id_documento_cliente [ $id_anagrafica ] = $id_documento ;
2018-03-22 15:40:20 +01:00
}
2018-08-31 12:33:48 +02:00
}
2018-03-22 15:40:20 +01:00
2023-08-04 14:54:28 +02:00
$descrizione = str_replace ( " ' " , ' ' , strip_tags ( $module -> replacePlaceholders ( $intervento [ 'id' ], setting ( 'Descrizione personalizzata in fatturazione' )))) ? : tr ( 'Attività numero _NUM_ del _DATE_' , [
2020-01-24 11:52:36 +01:00
'_NUM_' => $intervento [ 'codice_intervento' ],
2018-08-31 12:33:48 +02:00
'_DATE_' => Translator :: dateToLocale ( $intervento [ 'data' ]),
]);
2018-03-22 15:40:20 +01:00
2018-08-31 12:33:48 +02:00
aggiungi_intervento_in_fattura ( $intervento [ 'id' ], $id_documento , $descrizione , $id_iva , $id_conto );
2021-06-11 12:05:19 +02:00
$fatturati [] = $intervento [ 'id' ];
2018-09-03 16:49:43 +02:00
++ $n_interventi ;
2018-03-22 15:40:20 +01:00
}
if ( $n_interventi > 0 ) {
2018-09-03 16:01:05 +02:00
flash () -> info ( tr ( '_NUM_ interventi fatturati.' , [
2018-03-22 15:40:20 +01:00
'_NUM_' => $n_interventi ,
2018-07-07 13:56:22 +02:00
]));
2021-03-30 15:18:15 +02:00
}
2021-06-11 12:05:19 +02:00
if ( ! empty ( array_diff ( $id_records , $fatturati ))) {
2021-03-30 15:18:15 +02:00
flash () -> warning ( tr ( '_NUM_ interventi non sono stati fatturati.' , [
2021-06-11 12:05:19 +02:00
'_NUM_' => sizeof ( array_diff ( $id_records , $fatturati )),
2021-03-30 15:18:15 +02:00
]));
2018-03-08 17:29:32 +01:00
}
2018-03-22 15:40:20 +01:00
break ;
2020-03-09 16:36:35 +01:00
case 'cambia_stato' :
$id_stato = post ( 'id_stato' );
$n_interventi = 0 ;
$stato = Stato :: find ( $id_stato );
// Lettura righe selezionate
foreach ( $id_records as $id ) {
$intervento = Intervento :: find ( $id );
2022-04-11 12:44:42 +02:00
$intervento -> stato () -> associate ( $stato );
$intervento -> save ();
2020-03-09 16:36:35 +01:00
2022-04-11 12:44:42 +02:00
++ $n_interventi ;
2020-03-09 16:36:35 +01:00
}
if ( $n_interventi > 0 ) {
flash () -> info ( tr ( 'Stato cambiato a _NUM_ attività!' , [
'_NUM_' => $n_interventi ,
]));
} else {
flash () -> warning ( tr ( 'Nessuna attività modificata!' ));
}
2020-06-09 13:08:36 +02:00
break ;
2020-06-09 16:59:26 +02:00
2020-08-07 17:37:39 +02:00
case 'copy-bulk' :
2020-09-22 13:59:50 +02:00
$id_stato = post ( 'idstatointervento' );
2020-06-09 13:08:36 +02:00
$data_richiesta = post ( 'data_richiesta' );
$copia_sessioni = post ( 'sessioni' );
$copia_righe = post ( 'righe' );
2022-09-29 15:22:24 +02:00
$copia_impianti = post ( 'impianti' );
2020-06-09 13:08:36 +02:00
foreach ( $id_records as $idintervento ) {
$intervento = Intervento :: find ( $idintervento );
$new = $intervento -> replicate ();
2020-09-22 13:59:50 +02:00
$new -> idstatointervento = $id_stato ;
2020-06-09 13:08:36 +02:00
2020-09-22 13:59:50 +02:00
// Calcolo del nuovo codice sulla base della data di richiesta
2022-11-28 09:27:25 +01:00
$new -> codice = Intervento :: getNextCodice ( $data_richiesta , $new -> id_segment );
2020-06-09 13:08:36 +02:00
$new -> save ();
2020-06-09 16:59:26 +02:00
2020-06-09 13:08:36 +02:00
$id_record = $new -> id ;
2020-06-09 16:59:26 +02:00
2020-09-22 13:59:50 +02:00
// Copio le righe
if ( ! empty ( $copia_righe )) {
$righe = $intervento -> getRighe ();
foreach ( $righe as $riga ) {
$new_riga = $riga -> replicate ();
2020-09-22 20:28:37 +02:00
$new_riga -> setDocument ( $new );
2020-06-09 16:59:26 +02:00
2020-09-22 13:59:50 +02:00
$new_riga -> qta_evasa = 0 ;
$new_riga -> save ();
2020-06-09 13:08:36 +02:00
}
}
2020-06-09 16:59:26 +02:00
2020-09-22 13:59:50 +02:00
// Copia delle sessioni
$numero_sessione = 0 ;
if ( ! empty ( $copia_sessioni )) {
2020-06-09 13:08:36 +02:00
$sessioni = $intervento -> sessioni ;
foreach ( $sessioni as $sessione ) {
2020-09-22 13:59:50 +02:00
// Se è la prima sessione che copio importo la data con quella della richiesta
if ( $numero_sessione == 0 ) {
2020-06-09 16:59:26 +02:00
$orario_inizio = date ( 'Y-m-d' , strtotime ( $data_richiesta )) . ' ' . date ( 'H:i:s' , strtotime ( $sessione -> orario_inizio ));
} else {
2020-06-09 13:08:36 +02:00
$diff = strtotime ( $sessione -> orario_inizio ) - strtotime ( $inizio_old );
2020-09-22 13:59:50 +02:00
$orario_inizio = date ( 'Y-m-d H:i:s' , ( strtotime ( $sessione -> orario_inizio ) + $diff ));
2020-06-09 13:08:36 +02:00
}
2020-06-09 16:59:26 +02:00
2020-06-09 13:08:36 +02:00
$diff_fine = strtotime ( $sessione -> orario_fine ) - strtotime ( $sessione -> orario_inizio );
2020-06-09 16:59:26 +02:00
$orario_fine = date ( 'Y-m-d H:i:s' , ( strtotime ( $orario_inizio ) + $diff_fine ));
2020-06-09 13:08:36 +02:00
$new_sessione = $sessione -> replicate ();
$new_sessione -> idintervento = $new -> id ;
2020-06-09 16:59:26 +02:00
2020-06-09 13:08:36 +02:00
$new_sessione -> orario_inizio = $orario_inizio ;
$new_sessione -> orario_fine = $orario_fine ;
$new_sessione -> save ();
2020-06-09 16:59:26 +02:00
2020-09-22 13:59:50 +02:00
++ $numero_sessione ;
2020-06-09 13:08:36 +02:00
$inizio_old = $sessione -> orario_inizio ;
}
}
}
2022-09-29 15:22:24 +02:00
// Copia degli impianti
if ( ! empty ( $copia_impianti )) {
$impianti = $dbo -> select ( 'my_impianti_interventi' , '*' , [ 'idintervento' => $intervento -> id ]);
foreach ( $impianti as $impianto ) {
$dbo -> insert ( 'my_impianti_interventi' , [
'idintervento' => $id_record ,
2023-08-04 14:54:28 +02:00
'idimpianto' => $impianto [ 'idimpianto' ],
2022-09-29 15:22:24 +02:00
]);
}
$componenti = $dbo -> select ( 'my_componenti_interventi' , '*' , [ 'id_intervento' => $intervento -> id ]);
foreach ( $componenti as $componente ) {
$dbo -> insert ( 'my_componenti_interventi' , [
'id_intervento' => $id_record ,
2023-08-04 14:54:28 +02:00
'id_componente' => $componente [ 'id_componente' ],
2022-09-29 15:22:24 +02:00
]);
}
}
2020-06-09 13:08:36 +02:00
flash () -> info ( tr ( 'Attività duplicate correttamente!' ));
2020-03-09 16:36:35 +01:00
break ;
2021-04-13 14:43:54 +02:00
2023-03-31 17:24:59 +02:00
case 'delete-bulk' :
foreach ( $id_records as $id ) {
$intervento = Intervento :: find ( $id );
try {
// Eliminazione associazioni tra interventi e contratti
2023-08-04 14:54:28 +02:00
$dbo -> query ( 'UPDATE co_promemoria SET idintervento = NULL WHERE idintervento=' . prepare ( $id_record ));
2023-03-20 12:52:13 +01:00
2023-08-04 14:54:28 +02:00
$intervento -> delete ();
2023-03-20 12:52:13 +01:00
2023-08-04 14:54:28 +02:00
// Elimino il collegamento al componente
$dbo -> query ( 'DELETE FROM my_componenti WHERE id_intervento=' . prepare ( $id_record ));
2023-03-20 12:52:13 +01:00
2023-08-04 14:54:28 +02:00
// Eliminazione associazione tecnici collegati all'intervento
$dbo -> query ( 'DELETE FROM in_interventi_tecnici WHERE idintervento=' . prepare ( $id_record ));
2023-03-20 12:52:13 +01:00
2023-08-04 14:54:28 +02:00
// Eliminazione associazione interventi e my_impianti
$dbo -> query ( 'DELETE FROM my_impianti_interventi WHERE idintervento=' . prepare ( $id_record ));
2023-03-20 12:52:13 +01:00
2023-08-04 14:54:28 +02:00
// Elimino anche eventuali file caricati
Uploads :: deleteLinked ([
2023-03-31 17:24:59 +02:00
'id_module' => $id_module ,
'id_record' => $id_record ,
]);
} catch ( InvalidArgumentException $e ) {
2021-04-13 14:43:54 +02:00
}
2023-03-31 17:24:59 +02:00
}
2021-04-26 09:16:16 +02:00
2023-03-31 17:24:59 +02:00
flash () -> info ( tr ( 'Interventi eliminati!' ));
2022-03-07 17:36:41 +01:00
2023-03-31 17:24:59 +02:00
break ;
2022-03-07 17:36:41 +01:00
2023-03-31 17:24:59 +02:00
case 'stampa-riepilogo' :
$_SESSION [ 'superselect' ][ 'interventi' ] = $id_records ;
$id_print = Prints :: getPrints ()[ 'Riepilogo interventi' ];
2022-03-07 17:36:41 +01:00
2023-03-31 17:24:59 +02:00
redirect ( base_path () . '/pdfgen.php?id_print=' . $id_print . '&tipo=' . post ( 'tipo' ));
exit ();
2022-03-07 17:36:41 +01:00
2023-03-31 17:24:59 +02:00
case 'send-mail' :
$template = Template :: find ( post ( 'id_template' ));
2022-11-30 17:02:07 +01:00
2023-03-31 17:24:59 +02:00
$list = [];
foreach ( $id_records as $id ) {
$intervento = Intervento :: find ( $id );
$id_anagrafica = $intervento -> idanagrafica ;
// Selezione destinatari e invio mail
if ( ! empty ( $template )) {
$creata_mail = false ;
$emails = [];
// Aggiungo email anagrafica
if ( ! empty ( $intervento -> anagrafica -> email )) {
$emails [] = $intervento -> anagrafica -> email ;
$mail = Mail :: build ( auth () -> getUser (), $template , $id );
$mail -> addReceiver ( $intervento -> anagrafica -> email );
$creata_mail = true ;
}
2022-11-30 17:02:07 +01:00
2023-03-31 17:24:59 +02:00
// Aggiungo email referenti in base alla mansione impostata nel template
$mansioni = $dbo -> select ( 'em_mansioni_template' , 'idmansione' , [ 'id_template' => $template -> id ]);
foreach ( $mansioni as $mansione ) {
$referenti = $dbo -> table ( 'an_referenti' ) -> where ( 'idmansione' , $mansione [ 'idmansione' ]) -> where ( 'idanagrafica' , $id_anagrafica ) -> where ( 'email' , '!=' , '' ) -> get ();
if ( ! $referenti -> isEmpty () && $creata_mail == false ) {
2022-11-30 17:02:07 +01:00
$mail = Mail :: build ( auth () -> getUser (), $template , $id );
$creata_mail = true ;
}
2023-08-04 14:54:28 +02:00
2023-03-31 17:24:59 +02:00
foreach ( $referenti as $referente ) {
if ( ! in_array ( $referente -> email , $emails )) {
$emails [] = $referente -> email ;
$mail -> addReceiver ( $referente -> email );
2023-08-04 14:54:28 +02:00
}
2022-11-30 17:02:07 +01:00
}
}
2023-08-04 14:54:28 +02:00
if ( $creata_mail == true ) {
2023-03-31 17:24:59 +02:00
$mail -> save ();
OperationLog :: setInfo ( 'id_email' , $mail -> id );
OperationLog :: setInfo ( 'id_module' , $id_module );
OperationLog :: setInfo ( 'id_record' , $mail -> id_record );
OperationLog :: build ( 'send-email' );
array_push ( $list , $intervento -> codice );
}
2022-11-30 17:02:07 +01:00
}
2023-03-31 17:24:59 +02:00
}
2023-08-04 14:54:28 +02:00
if ( $list ) {
2023-03-31 17:24:59 +02:00
flash () -> info ( tr ( 'Mail inviata per le attività _LIST_ !' , [
'_LIST_' => implode ( ',' , $list ),
]));
}
break ;
2018-02-09 15:43:51 +01:00
}
2021-04-13 14:43:54 +02:00
if ( App :: debug ()) {
$operations [ 'delete-bulk' ] = [
2021-09-20 13:33:45 +02:00
'text' => '<span><i class="fa fa-trash"></i> ' . tr ( 'Elimina selezionati' ) . '</span> <span class="label label-danger">beta</span>' ,
2021-04-13 14:43:54 +02:00
];
}
$operations [ 'export-bulk' ] = [
2020-07-09 18:50:10 +02:00
'text' => '<span><i class="fa fa-file-archive-o"></i> ' . tr ( 'Esporta stampe' ),
2018-02-09 15:43:51 +01:00
'data' => [
2020-11-12 10:13:23 +01:00
'title' => tr ( 'Vuoi davvero esportare queste stampe in un archivio ZIP?' ),
2018-07-23 13:47:09 +02:00
'msg' => '' ,
2020-11-12 10:13:23 +01:00
'button' => tr ( 'Procedi' ),
2018-02-09 15:43:51 +01:00
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
2021-04-13 14:43:54 +02:00
];
2018-03-22 15:40:20 +01:00
2021-04-13 14:43:54 +02:00
$operations [ 'crea_fattura' ] = [
2020-11-12 17:11:09 +01:00
'text' => '<span><i class="fa fa-file-code-o"></i> ' . tr ( 'Fattura _TYPE_' , [ '_TYPE_' => strtolower ( $module [ 'name' ])]),
2018-03-08 17:29:32 +01:00
'data' => [
2020-11-12 17:11:09 +01:00
'title' => tr ( 'Fatturare gli _TYPE_ selezionati?' , [ '_TYPE_' => strtolower ( $module [ 'name' ])]) . ' <small><i class="fa fa-question-circle-o tip" title="' . tr ( 'Verranno fatturati solo gli interventi completati non collegati a contratti o preventivi' ) . '."></i></small>' ,
'msg' => '{[ "type": "checkbox", "label": "<small>' . tr ( 'Aggiungere alle fatture di vendita non ancora emesse?' ) . '</small>", "placeholder": "' . tr ( 'Aggiungere alle fatture di vendita nello stato bozza?' ) . ' " , " name " : " accodare " ]}<br>
2023-08-04 14:54:28 +02:00
{[ " type " : " select " , " label " : " '.tr('Sezionale').' " , " name " : " id_segment " , " required " : 1 , " ajax-source " : " segmenti " , " select-options " : '.json_encode([' id_module ' => $id_fatture, ' is_sezionale ' => 1]).' , " value " : " '. $id_segment .' " , " select-options-escape " : true ]} < br >
2021-09-03 17:57:49 +02:00
{[ " type " : " select " , " label " : " '.tr('Tipo documento').' " , " name " : " idtipodocumento " , " required " : 1 , " values " : " query=SELECT id, CONCAT(codice_tipo_documento_fe, \ ' - \ ', descrizione) AS descrizione FROM co_tipidocumento WHERE enabled = 1 AND dir = \ 'entrata \ ' ORDER BY codice_tipo_documento_fe " , " value " : " '. $idtipodocumento .' " ]} ' ,
2020-11-12 10:13:23 +01:00
'button' => tr ( 'Procedi' ),
2018-03-08 17:29:32 +01:00
'class' => 'btn btn-lg btn-warning' ,
'blank' => false ,
],
2021-04-13 14:43:54 +02:00
];
2020-03-09 16:36:35 +01:00
2021-04-13 14:43:54 +02:00
$operations [ 'cambia_stato' ] = [
2020-07-09 18:50:10 +02:00
'text' => '<span><i class="fa fa-refresh"></i> ' . tr ( 'Cambia stato' ),
2020-03-09 16:36:35 +01:00
'data' => [
2021-01-19 12:20:06 +01:00
'title' => tr ( 'Vuoi davvero cambiare lo stato per questi interventi?' ),
2020-03-09 16:36:35 +01:00
'msg' => tr ( 'Seleziona lo stato in cui spostare tutti gli interventi non completati' ) . ' .< br >
2022-02-22 14:53:07 +01:00
< br > {[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " id_stato " , " required " : 1 , " values " : " query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL ORDER BY descrizione " ]} ' ,
2020-11-12 10:13:23 +01:00
'button' => tr ( 'Procedi' ),
2020-03-09 16:36:35 +01:00
'class' => 'btn btn-lg btn-warning' ,
'blank' => false ,
],
2021-04-13 14:43:54 +02:00
];
2020-06-09 16:59:26 +02:00
2021-04-13 14:43:54 +02:00
$operations [ 'copy-bulk' ] = [
2020-07-09 18:50:10 +02:00
'text' => '<span><i class="fa fa-clone"></i> ' . tr ( 'Duplica attività' ),
2020-06-09 13:08:36 +02:00
'data' => [
'title' => tr ( 'Vuoi davvero fare una copia degli interventi selezionati?' ),
'msg' => '<br>{[ "type": "timestamp", "label": "' . tr ( 'Data/ora richiesta' ) . ' " , " name " : " data_richiesta " , " required " : 0, " value " : " - now - " , " required " :1 ]}
2022-02-22 14:53:07 +01:00
< br > {[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstatointervento " , " required " : 1 , " values " : " query=SELECT idstatointervento AS id, descrizione, colore AS _bgcolor_ FROM in_statiintervento WHERE deleted_at IS NULL ORDER BY descrizione " , " value " : " " ]}
2020-06-09 13:08:36 +02:00
< br > {[ " type " : " checkbox " , " label " : " '.tr('Duplica righe').' " , " name " : " righe " , " value " : " " ]}
2022-09-29 15:22:24 +02:00
< br > {[ " type " : " checkbox " , " label " : " '.tr('Duplica sessioni').' " , " name " : " sessioni " , " value " : " " ]}
2022-10-11 12:00:22 +02:00
< br > {[ " type " : " checkbox " , " label " : " '.tr('Duplica impianti').' " , " name " : " impianti " , " value " : " " ]}
< style >. swal2 - modal { width : 600 px ! important ; } </ style > ' ,
2020-11-12 10:13:23 +01:00
'button' => tr ( 'Procedi' ),
2020-06-09 13:08:36 +02:00
'class' => 'btn btn-lg btn-warning' ,
'blank' => false ,
],
2021-04-13 14:43:54 +02:00
];
2022-03-07 17:36:41 +01:00
$operations [ 'stampa-riepilogo' ] = [
'text' => '<span><i class="fa fa-print"></i> ' . tr ( 'Stampa riepilogo' ),
'data' => [
'title' => tr ( 'Stampare il riepilogo delle attività selezionate?' ),
'msg' => '<br>{[ "type": "select", "label": "' . tr ( 'Stampa riepilogo' ) . '", "name": "tipo", "required": "1", "values": "list=\"cliente\": \"Clienti\", \"interno\": \"Interno\"", "value": "cliente" ]}' ,
'button' => tr ( 'Stampa' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => true ,
],
];
2022-11-30 17:02:07 +01:00
$operations [ 'send-mail' ] = [
'text' => '<span><i class="fa fa-envelope"></i> ' . tr ( 'Invia mail' ) . '</span>' ,
'data' => [
'title' => tr ( 'Inviare mail?' ),
'msg' => tr ( 'Per ciascuna attività selezionata, verrà inviata una mail' ) . ' < br >< br >
{[ " type " : " select " , " label " : " '.tr('Template').' " , " name " : " id_template " , " required " : " 1 " , " values " : " query=SELECT id, name AS descrizione FROM em_templates WHERE id_module='.prepare( $id_module ).' AND deleted_at IS NULL; " ]} ' ,
'button' => tr ( 'Invia' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
2023-03-31 17:24:59 +02:00
$operations [ 'firma-intervento' ] = [
'text' => '<span><i class="fa fa-pencil"></i> ' . tr ( 'Firma interventi' ) . '</span>' ,
'data' => [
'title' => tr ( 'Firma' ),
'type' => 'modal' ,
'origine' => 'interventi' ,
'url' => $module -> fileurl ( 'modals/firma.php' ),
],
];
2021-04-13 14:43:54 +02:00
return $operations ;