2018-10-12 10:33:08 +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 />.
*/
2018-10-12 10:33:08 +02:00
2019-12-05 15:50:13 +01:00
include_once __DIR__ . '/../../../core.php' ;
2020-08-17 09:47:18 +02:00
include_once __DIR__ . '/../../../../core.php' ;
2018-10-12 10:33:08 +02:00
2022-02-10 11:13:48 +01:00
use Modules\Interventi\Intervento ;
2022-02-10 09:57:22 +01:00
$show_prezzi = true ;
2018-10-12 10:33:08 +02:00
// Limitazione delle azioni dei tecnici
if ( $user [ 'gruppo' ] == 'Tecnici' ) {
2022-02-10 09:57:22 +01:00
$show_prezzi = ! empty ( $user [ 'idanagrafica' ]) && setting ( 'Mostra i prezzi al tecnico' );
2018-10-12 10:33:08 +02:00
}
2019-07-12 15:12:24 +02:00
$sessione = $dbo -> fetchOne ( 'SELECT in_interventi_tecnici.*, an_anagrafiche.ragione_sociale, an_anagrafiche.deleted_at, in_interventi_tecnici.tipo_scontokm AS tipo_sconto_km, in_interventi_tecnici.prezzo_ore_unitario, in_interventi_tecnici.prezzo_km_unitario, in_interventi_tecnici.prezzo_dirittochiamata FROM in_interventi_tecnici INNER JOIN an_anagrafiche ON in_interventi_tecnici.idtecnico = an_anagrafiche.idanagrafica WHERE in_interventi_tecnici.id = ' . prepare ( get ( 'id_sessione' )));
2018-10-12 10:33:08 +02:00
2018-10-30 11:39:45 +01:00
$op = 'edit_sessione' ;
$button = '<i class="fa fa-edit"></i> ' . tr ( 'Modifica' );
2018-10-12 10:33:08 +02:00
2022-02-10 11:13:48 +01:00
$intervento = Intervento :: find ( $id_record );
if ( ! empty ( $intervento -> id_contratto )) {
$query = 'SELECT in_tipiintervento.idtipointervento AS id, descrizione, co_contratti_tipiintervento.costo_ore AS prezzo_ore_unitario, co_contratti_tipiintervento.costo_km AS prezzo_km_unitario, co_contratti_tipiintervento.costo_dirittochiamata AS prezzo_dirittochiamata FROM in_tipiintervento JOIN co_contratti_tipiintervento ON in_tipiintervento.idtipointervento = co_contratti_tipiintervento.idtipointervento WHERE co_contratti_tipiintervento.idcontratto = ' . prepare ( $intervento -> id_contratto ) . ' ORDER BY descrizione' ;
} else {
$query = 'SELECT in_tipiintervento.idtipointervento AS id, descrizione, in_tariffe.costo_ore AS prezzo_ore_unitario, in_tariffe.costo_km AS prezzo_km_unitario, in_tariffe.costo_dirittochiamata AS prezzo_dirittochiamata FROM in_tipiintervento JOIN in_tariffe ON in_tipiintervento.idtipointervento = in_tariffe.idtipointervento WHERE in_tariffe.idtecnico = ' . prepare ( $sessione [ 'idtecnico' ]) . ' ORDER BY descrizione' ;
}
2018-10-12 10:33:08 +02:00
echo '
2020-12-31 16:13:28 +01:00
< form id = " add_form " action = " '.base_url().'/editor.php?id_module='. $id_module .'&id_record='.get('id_record').' " method = " post " >
2018-10-12 10:33:08 +02:00
< input type = " hidden " name = " op " value = " '. $op .' " >
2018-10-30 11:39:45 +01:00
< input type = " hidden " name = " backto " value = " record-edit " >
2018-12-20 16:33:15 +01:00
< input type = " hidden " name = " id_sessione " value = " '. $sessione['id'] .' " >
< input type = " hidden " name = " idtecnico " value = " '. $sessione['idtecnico'] .' " > ' ;
2018-10-12 10:33:08 +02:00
// Tecnico
echo '
2019-06-11 18:35:07 +02:00
< div class = " row " >
< div class = " col-md-4 " >
{[ " type " : " span " , " label " : " '.tr('Tecnico').' " , " name " : " tecnico " , " required " : 0 , " value " : " '. $sessione['ragione_sociale'] .' '.(!empty( $sessione['deleted_at'] ) ? '<small class= " text - danger " ><em>('.tr('Eliminato').')</em></small>' : '').' " ]}
</ div >
2018-10-12 10:33:08 +02:00
2018-10-30 11:39:45 +01:00
< div class = " col-md-4 " >
2022-02-10 11:13:48 +01:00
{[ " type " : " select " , " label " : " '.tr('Tipo attività').' " , " name " : " idtipointerventot " , " value " : " '. $sessione['idtipointervento'] .' " , " required " : 1 , " values " : " query='. $query .' " ]}
2018-10-30 11:39:45 +01:00
</ div >
2021-11-02 09:43:07 +01:00
</ div > ' ;
2020-01-10 18:55:20 +01:00
2022-02-10 09:57:22 +01:00
$class = $show_prezzi ? '' : 'hide' ;
2021-11-02 09:43:07 +01:00
// Orari
echo '
< div class = " row " >
2018-10-30 11:39:45 +01:00
< div class = " col-md-4 " >
2018-10-12 10:33:08 +02:00
{[ " type " : " timestamp " , " label " : " '.tr('Inizio attività').' " , " name " : " orario_inizio " , " required " : 1 , " value " : " '. $sessione['orario_inizio'] .' " ]}
</ div >
2018-10-30 11:39:45 +01:00
< div class = " col-md-4 " >
2018-10-12 10:33:08 +02:00
{[ " type " : " timestamp " , " label " : " '.tr('Fine attività').' " , " name " : " orario_fine " , " required " : 1 , " value " : " '. $sessione['orario_fine'] .' " ]}
</ div >
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " '.tr('Km').' " , " name " : " km " , " value " : " '. $sessione['km'] .' " ]}
2021-11-02 09:43:07 +01:00
</ div >
2019-07-08 17:11:48 +02:00
</ div >
2020-01-10 18:55:20 +01:00
2019-07-08 17:11:48 +02:00
< div class = " row " >
2020-01-10 18:55:20 +01:00
< div class = " col-md-4 '. $class .' " >
2019-07-08 17:11:48 +02:00
{[ " type " : " number " , " label " : " '.tr('Addebito orario').' " , " name " : " prezzo_ore_unitario " , " value " : " '. $sessione['prezzo_ore_unitario'] .' " ]}
</ div >
2020-01-10 18:55:20 +01:00
< div class = " col-md-4 '. $class .' " >
2021-11-02 09:43:07 +01:00
{[ " type " : " number " , " label " : " '.tr('Addebito al km').' " , " name " : " prezzo_km_unitario " , " value " : " '. $sessione['prezzo_km_unitario'] .' " ]}
2019-07-08 17:11:48 +02:00
</ div >
2020-01-10 18:55:20 +01:00
< div class = " col-md-4 '. $class .' " >
2019-07-08 17:11:48 +02:00
{[ " type " : " number " , " label " : " '.tr('Addebito diritto ch.').' " , " name " : " prezzo_dirittochiamata " , " value " : " '. $sessione['prezzo_dirittochiamata'] .' " ]}
2021-11-02 09:43:07 +01:00
</ div >
</ div >
< div class = " row " > ' ;
// Sconto ore
echo '
< div class = " col-md-4 '. $class .' " >
{[ " type " : " number " , " label " : " '.tr('Sconto orario').' " , " name " : " sconto " , " value " : " '. $sessione['sconto_unitario'] .' " , " icon-after " : " choice|untprc|'. $sessione['tipo_sconto'] .' " ]}
2019-12-09 17:47:07 +01:00
</ div > ' ;
2019-12-13 10:08:17 +01:00
2021-11-02 09:43:07 +01:00
// Sconto km
2021-02-18 18:48:44 +01:00
echo '
2021-11-02 09:43:07 +01:00
< div class = " col-md-4 '. $class .' " >
{[ " type " : " number " , " label " : " '.tr('Sconto al km').' " , " name " : " sconto_km " , " value " : " '. $sessione['scontokm_unitario'] .' " , " icon-after " : " choice|untprc|'. $sessione['tipo_sconto_km'] .' " ]}
</ div > ' ;
2019-12-09 17:47:07 +01:00
2021-11-02 09:43:07 +01:00
echo '
</ div >
2018-10-12 10:33:08 +02:00
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary " > '.$button.' </ button >
</ div >
</ div >
</ form > ' ;
echo '
2019-07-26 18:05:19 +02:00
< script > $ ( document ) . ready ( init ) </ script > ' ;
2018-10-12 10:33:08 +02:00
echo '
< script >
$ ( document ) . ready ( function () {
// Quando modifico orario inizio, allineo anche l\'orario fine
$ ( " #orario_inizio " ) . on ( " dp.change " , function ( e ) {
2019-08-02 15:58:31 +02:00
$ ( " #orario_fine " ) . data ( " DateTimePicker " ) . minDate ( e . date );
$ ( " #orario_fine " ) . change ();
2018-10-12 10:33:08 +02:00
});
2019-07-08 17:11:48 +02:00
$ ( " #idtipointerventot " ) . change ( function () {
data = $ ( this ) . selectData ();
2020-01-10 18:55:20 +01:00
2019-07-08 17:11:48 +02:00
$ ( " #prezzo_ore_unitario " ) . val ( data . prezzo_ore_unitario );
$ ( " #prezzo_km_unitario " ) . val ( data . prezzo_km_unitario );
$ ( " #prezzo_dirittochiamata " ) . val ( data . prezzo_dirittochiamata );
});
2018-10-12 10:33:08 +02:00
});
2020-01-14 22:30:46 +01:00
</ script > ' ;