2018-02-22 11:07:52 +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-22 11:07:52 +01:00
include_once __DIR__ . '/../../core.php' ;
2018-11-22 11:34:07 +01:00
$rs_documento = $dbo -> fetchArray ( 'SELECT * FROM co_righe_contratti WHERE idcontratto=' . prepare ( $id_record ));
2019-02-14 17:49:58 +01:00
2020-07-20 17:26:50 +02:00
$is_fatturabile = $record [ 'is_fatturabile' ] && ! empty ( $rs_documento );
2019-11-12 16:58:45 +01:00
2019-11-15 15:11:20 +01:00
$stati_fatturabili = $dbo -> fetchOne ( 'SELECT GROUP_CONCAT(`descrizione` SEPARATOR ", ") AS stati_abilitati FROM `co_staticontratti` WHERE `is_fatturabile` = 1' )[ 'stati_abilitati' ];
2019-11-12 16:58:45 +01:00
2018-11-22 11:34:07 +01:00
/* permetto di fatturare il contratto solo se contiene righe e si trova in uno stato fatturabile */
2018-11-30 16:10:15 +01:00
echo '
2020-07-20 17:26:50 +02:00
< div class = " tip " data - toggle = " tooltip " title = " '.tr('Per creare un documento deve essere inserita almeno una riga e lo stato del contratto deve essere tra: _STATE_LIST_', [
'_STATE_LIST_' => $stati_fatturabili ,
]) . ' " >
< button type = " button " class = " btn btn-info '.( $is_fatturabile ? '' : 'disabled').' " data - href = " '. $structure->fileurl ('crea_documento.php').'?id_module='. $id_module .'&id_record='. $id_record .'&documento=fattura " data - toggle = " modal " data - title = " '.tr('Crea fattura').' " >
< i class = " fa fa-magic " ></ i > '.tr(' Crea fattura ').'
</ button >
</ div > ' ;
2018-11-22 11:34:07 +01:00
2022-01-20 11:30:08 +01:00
$rinnova = ! empty ( $record [ 'data_accettazione' ]) && ! empty ( $record [ 'data_conclusione' ]) && $record [ 'data_accettazione' ] != '0000-00-00' && $record [ 'data_conclusione' ] != '0000-00-00' && $record [ 'is_completato' ] && $record [ 'rinnovabile' ];
2019-11-12 18:45:52 +01:00
2022-01-20 11:30:08 +01:00
$stati_completati = $dbo -> fetchOne ( 'SELECT GROUP_CONCAT(`descrizione` SEPARATOR ", ") AS stati_completati FROM `co_staticontratti` WHERE `is_completato` = 1' )[ 'stati_completati' ];
2019-11-12 18:45:52 +01:00
echo '
2021-12-21 15:51:40 +01:00
< div class = " tip " data - toggle = " tooltip " title = " '.tr('Il contratto è rinnovabile se sono definite le date di accettazione e conclusione e si trova in uno di questi stati: _STATE_LIST_', [
2022-01-20 11:30:08 +01:00
'_STATE_LIST_' => $stati_completati ,
2021-09-20 17:49:30 +02:00
]) . ' " id= " rinnova " >
2020-07-20 17:26:50 +02:00
< button type = " button " class = " btn btn-warning ask '.( $rinnova ? '' : 'disabled').' " data - backto = " record-edit " data - op = " renew " data - msg = " '.tr('Rinnovare questo contratto?').' " data - button = " '.tr('Rinnova').' " data - class = " btn btn-lg btn-warning " >
< i class = " fa fa-refresh " ></ i > '.tr(' Rinnova ').' ...
</ button >
</ div > ' ;
2019-02-14 17:49:58 +01:00
2019-04-08 18:50:28 +02:00
// Duplica contratto
2021-02-18 18:48:44 +01:00
echo '
2022-07-21 12:11:04 +02:00
< button type = " button " class = " btn btn-primary " onclick = " copiaContratto(); " >
2020-07-31 08:56:41 +02:00
< i class = " fa fa-copy " ></ i > '.tr(' Duplica contratto ').'
</ button > ' ;
2019-11-12 18:45:52 +01:00
2019-04-08 18:50:28 +02:00
echo '
< form action = " " method = " post " id = " copia-contratto " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " copy " >
2019-04-12 01:11:32 +02:00
</ form > ' ;
2022-07-21 12:11:04 +02:00
echo '
< script >
function copiaContratto () {
swal ({
title : " '.tr('Duplicare il contratto?').' " ,
text : " '.tr('').' " ,
type : " info " ,
showCancelButton : true ,
confirmButtonClass : " btn btn-lg btn-primary " ,
confirmButtonText : " '.tr('Duplica').' " ,
}) . then (
function () {
$ ( " #copia-contratto " ) . submit ();
},
function () {}
);
}
</ script > ' ;