2019-07-25 15:06:07 +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-25 15:06:07 +02:00
include_once __DIR__ . '/../../core.php' ;
2021-12-10 12:45:44 +01:00
use Modules\Anagrafiche\Anagrafica ;
use Modules\Fatture\Fattura ;
use Modules\Scadenzario\Scadenza ;
$anagrafica_azienda = Anagrafica :: find ( setting ( 'Azienda predefinita' ));
2021-12-07 13:05:41 +01:00
switch ( post ( 'op' )) {
case 'change_distinta' :
$distinta = post ( 'distinta' );
$n_scadenze = 0 ;
foreach ( $id_records as $id ) {
$database -> update ( 'co_scadenziario' , [
'distinta' => $distinta ,
], [ 'id' => $id ]);
++ $n_scadenze ;
}
if ( $n_scadenze > 0 ) {
2022-03-10 11:34:01 +01:00
flash () -> info ( tr ( 'Info distinta aggiornata a _NUM_ scadenze!' , [
2021-12-07 13:05:41 +01:00
'_NUM_' => $n_scadenze ,
]));
} else {
flash () -> warning ( tr ( 'Nessuna scadenza modificata!' ));
}
2021-12-10 12:45:44 +01:00
break ;
case 'change-bank' :
$list = [];
foreach ( $id_records as $id ) {
$scadenza = Scadenza :: find ( $id );
if ( $scadenza -> iddocumento ){
$documento = Fattura :: find ( $scadenza -> iddocumento );
$documento -> id_banca_azienda = post ( 'id_banca' );
$documento -> save ();
array_push ( $list , $documento -> numero_esterno );
}
}
if ( $list ){
flash () -> info ( tr ( 'Banca aggiornata per le Fatture _LIST_ !' , [
'_LIST_' => implode ( ',' , $list ),
]));
}
break ;
2021-12-07 13:05:41 +01:00
}
2019-07-25 15:06:07 +02:00
$operations [ 'registrazione-contabile' ] = [
'text' => '<span><i class="fa fa-calculator"></i> ' . tr ( 'Registrazione contabile' ) . '</span>' ,
'data' => [
'title' => tr ( 'Registrazione contabile' ),
'type' => 'modal' ,
'origine' => 'scadenzario' ,
2020-09-23 17:53:19 +02:00
'url' => base_path () . '/add.php?id_module=' . Modules :: get ( 'Prima nota' )[ 'id' ],
2019-07-25 15:06:07 +02:00
],
];
2021-12-07 13:05:41 +01:00
$operations [ 'change_distinta' ] = [
2022-03-10 11:34:01 +01:00
'text' => '<span><i class="fa fa-edit"></i> ' . tr ( 'Info distinta' ),
2021-12-07 13:05:41 +01:00
'data' => [
2022-03-10 11:34:01 +01:00
'title' => tr ( 'Modificare le informazioni della distinta?' ),
'msg' => tr ( 'Per ciascuna scadenza selezionata verrà modificata l\'informazione della distinta associata' ) . ' .< br >
< br > {[ " type " : " text " , " label " : " '.tr('Info distinta').' " , " name " : " distinta " , " required " : 1 ]} ' ,
2021-12-07 13:05:41 +01:00
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
'blank' => false ,
],
];
2021-12-10 12:45:44 +01:00
$operations [ 'change-bank' ] = [
'text' => '<span><i class="fa fa-refresh"></i> ' . tr ( 'Aggiorna banca' ) . '</span>' ,
'data' => [
'title' => tr ( 'Aggiornare la banca?' ),
'msg' => tr ( 'Per ciascuna scadenza selezionata, verrà aggiornata la banca della fattura di riferimento e quindi di conseguenza di tutte le scadenze collegate' ) . '
< br >< br > {[ " type " : " select " , " label " : " '.tr('Banca').' " , " name " : " id_banca " , " required " : 1 , " values " : " query=SELECT id, CONCAT (nome, \ ' - \ ' , iban) AS descrizione FROM co_banche WHERE id_anagrafica='.prepare( $anagrafica_azienda->idanagrafica ).' " ]} ' ,
'button' => tr ( 'Procedi' ),
'class' => 'btn btn-lg btn-warning' ,
],
];
2019-07-25 15:06:07 +02:00
return $operations ;