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
2018-02-18 19:53:23 +01:00
include_once __DIR__ . '/../../core.php' ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2024-03-22 15:52:24 +01:00
use Modules\Contratti\Stato ;
2017-08-04 16:28:16 +02:00
2023-02-10 14:55:02 +01:00
$id_anagrafica = ! empty ( get ( 'idanagrafica' )) ? get ( 'idanagrafica' ) : '' ;
2018-07-03 11:37:15 +02:00
2024-04-18 17:44:05 +02:00
$stati = get ( 'pianificabile' ) ? 'SELECT `co_staticontratti`.`id`, `title` AS descrizione FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ') WHERE `is_pianificabile`=1' : 'SELECT `co_staticontratti`.`id`, `title` AS descrizione FROM `co_staticontratti` LEFT JOIN `co_staticontratti_lang` ON (`co_staticontratti`.`id` = `co_staticontratti_lang`.`id_record` AND `co_staticontratti_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ')' ;
2024-02-09 12:08:55 +01:00
2024-06-11 16:58:27 +02:00
$stato = Stato :: where ( 'name' , 'Bozza' ) -> first () -> id ;
2022-02-16 17:47:19 +01:00
2021-09-01 10:52:22 +02:00
echo '
< form action = " " method = " post " id = " add-form " >
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " op " value = " add " >
< input type = " hidden " name = " backto " value = " record-edit " >
2022-03-09 10:33:55 +01:00
<!-- Fix creazione da Anagrafica -->
2024-04-11 11:17:03 +02:00
< input type = " hidden " name = " id_record " value = " 0 " >
2022-03-09 10:33:55 +01:00
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-6 " >
2021-09-01 10:52:22 +02:00
{[ " type " : " text " , " label " : " '.tr('Nome').' " , " name " : " nome " , " required " : 1 ]}
2017-08-04 16:28:16 +02:00
</ div >
< div class = " col-md-6 " >
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " '.tr('Cliente').' " , " name " : " idanagrafica " , " required " : 1 , " value " : " '. $id_anagrafica .' " , " ajax-source " : " clienti " , " icon-after " : " add|'.Module::where('name', 'Anagrafiche')->first()->id.'|tipoanagrafica=Cliente&readonly_tipo=1 " , " readonly " : " '.((empty(get('idanagrafica'))) ? 0 : 1).' " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2022-02-16 17:47:19 +01:00
< div class = " row " >
2022-11-28 09:27:25 +01:00
< div class = " col-md-6 " >
2023-03-17 17:49:43 +01:00
{[ " type " : " select " , " label " : " '.tr('Stato').' " , " name " : " idstato " , " required " : 1 , " value " : " '. $stato .' " , " values " : " query='. $stati .' " ]}
2022-02-16 17:47:19 +01:00
</ div >
2022-11-28 09:27:25 +01:00
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " '.tr('Sezionale').' " , " name " : " id_segment " , " required " : 1 , " ajax-source " : " segmenti " , " select-options " : '.json_encode([' id_module ' => $id_module, ' is_sezionale ' => 1]).' , " value " : " '. $_SESSION['module_'.$id_module] ['id_segment'].' " ]}
</ div >
</ div >
2024-11-25 15:59:41 +01:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " '.tr('Categoria').' " , " name " : " id_categoria " , " required " : 0 , " value " : " $id_categoria $ " , " ajax-source " : " categorie_contratti " ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " select " , " label " : " '.tr('Sottocategoria').' " , " name " : " id_sottocategoria " , " required " : 0 , " value " : " $id_sottocategoria $ " , " ajax-source " : " sottocategorie_contratti " , " select-options " : '.json_encode([' id_categoria ' => null]).' ]}
</ div >
</ div >
2022-11-28 09:27:25 +01:00
< div class = " row " >
< div class = " col-md-4 " >
2022-02-16 17:47:19 +01:00
{[ " type " : " date " , " label " : " '.tr('Data accettazione').' " , " name " : " data_accettazione " ]}
</ div >
2022-11-28 09:27:25 +01:00
< div class = " col-md-4 " >
2022-02-16 17:47:19 +01:00
{[ " type " : " date " , " label " : " '.tr('Data conclusione').' " , " name " : " data_conclusione " ]}
</ div >
2022-11-28 09:27:25 +01:00
< div class = " col-md-4 " >
2022-02-16 17:47:19 +01:00
{[ " type " : " number " , " label " : " '.tr('Validità contratto').' " , " name " : " validita " , " decimals " : " 0 " , " icon-after " : " choice|period|'. $record['tipo_validita'] .' " , " help " : " '.tr('Il campo Validità contratto viene utilizzato per il calcolo della Data di conclusione del contratto').' " ]}
</ div >
</ div >
2021-09-01 10:52:22 +02:00
<!-- Informazioni rinnovo -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary collapsable collapsed-card " >
< div class = " card-header " >
< h3 class = " card-title " > '.tr(' Informazioni per rinnovo ').' </ h3 >
< div class = " card-tools pull-right " >
2024-05-23 17:51:21 +02:00
< button type = " button " class = " btn btn-tool " data - card - widget = " collapse " >
2022-02-16 17:47:19 +01:00
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
2021-09-01 10:52:22 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2021-09-01 10:52:22 +02:00
< div class = " row " >
< div class = " col-md-6 " >
2024-05-30 10:53:28 +02:00
{[ " type " : " checkbox " , " label " : " '.tr('Rinnovabile').' " , " name " : " rinnovabile_add " , " value " : " '.setting('Crea contratto rinnovabile di default').' " , " id " : " rinnovabile_add " , " help " : " '.tr('Il contratto è rinnovabile?').' " ]}
2021-09-01 10:52:22 +02:00
</ div >
< div class = " col-md-6 " >
2024-10-23 12:05:31 +02:00
{[ " type " : " checkbox " , " label " : " '.tr('Tacito rinnovo').' " , " name " : " rinnovo_automatico_add " , " id " : " rinnovo_automatico_add " , " help " : " '.tr('Il contratto è da rinnovare automaticamente alla scadenza').' " , " disabled " : 1 ]}
2021-09-01 10:52:22 +02:00
</ div >
< div class = " col-md-6 " >
2023-10-27 10:35:05 +02:00
{[ " type " : " number " , " label " : " '.tr('Preavviso per rinnovo').' " , " name " : " giorni_preavviso_rinnovo " , " id " : " giorni_preavviso_rinnovo_add " , " decimals " : " 2 " , " value " : " '.setting('Giorni di preavviso di default').' " , " icon-after " : " giorni " , " disabled " : 1 ]}
2021-09-01 10:52:22 +02:00
</ div >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " '.tr('Ore rimanenti rinnovo').' " , " name " : " ore_preavviso_rinnovo " , " id " : " ore_preavviso_rinnovo_add " , " decimals " : " 2 " , " icon-after " : " ore " , " disabled " : 1 , " help " : " '.tr('Ore residue nel contratto prima di visualizzare una avviso per un eventuale rinnovo anticipato.').' " ]}
</ div >
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
2021-09-01 10:52:22 +02:00
< button type = " submit " class = " btn btn-primary " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ form >
2021-09-01 10:52:22 +02:00
< script type = " text/javascript " >
2024-10-09 09:55:44 +02:00
input ( " rinnovabile_add " ) . on ( " change " , function () {
2021-09-01 10:52:22 +02:00
const disabled = parseInt ( $ ( this ) . val ()) === 0 ;
input ( " giorni_preavviso_rinnovo " ) . setDisabled ( disabled );
input ( " ore_preavviso_rinnovo " ) . setDisabled ( disabled );
2024-10-23 12:05:31 +02:00
input ( " rinnovo_automatico_add " ) . setDisabled ( disabled );
2021-09-01 10:52:22 +02:00
});
2022-02-16 17:47:19 +01:00
$ ( " #data_conclusione " ) . on ( " dp.change " , function ( e ) {
let data_accettazione = $ ( " #data_accettazione " );
data_accettazione . data ( " DateTimePicker " ) . maxDate ( e . date );
if ( data_accettazione . data ( " DateTimePicker " ) . date () > e . date ){
data_accettazione . data ( " DateTimePicker " ) . date ( e . date );
}
});
2024-11-25 15:59:41 +01:00
$ ( " #id_categoria " ) . change ( function () {
updateSelectOption ( " id_categoria " , $ ( this ) . val ());
$ ( " #id_sottocategoria " ) . val ( null ) . trigger ( " change " );
});
2021-09-01 10:52:22 +02:00
</ script > ' ;