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
include_once __DIR__ . '/../../core.php' ;
2019-07-24 12:42:45 +02:00
$block_edit = $record [ 'is_completato' ];
2020-04-01 17:17:26 +02:00
// Mostro un avviso se ci sono più revisioni del preventivo
2020-04-01 17:28:21 +02:00
if ( count ( $preventivo -> revisioni ) > 1 ) {
2020-04-01 17:17:26 +02:00
echo '
< div class = " alert alert-info " >
2020-07-07 17:32:03 +02:00
< i class = " fa fa-info-circle " ></ i >
2020-04-14 08:49:48 +02:00
'.tr(' Questo preventivo presenta _N_ revisioni ' ,
2020-04-01 17:17:26 +02:00
[
2020-04-14 08:49:48 +02:00
'_N_' => count ( $preventivo -> revisioni ),
2020-04-01 17:17:26 +02:00
]) . '
</ div >
' ;
}
2018-02-23 16:04:50 +01:00
?> <form action="" method="post" id="edit-form">
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
2018-02-18 19:53:23 +01:00
< input type = " hidden " name = " id_record " value = " <?php echo $id_record ; ?> " >
2017-08-04 16:28:16 +02:00
<!-- DATI INTESTAZIONE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2019-07-24 12:42:45 +02:00
< h3 class = " panel-title " >< ? php echo tr ( 'Intestazione' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
< div class = " panel-body " >
< div class = " row " >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
2020-04-14 08:49:48 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Numero'); ?> " , " name " : " numero " , " required " : 1 , " class " : " text-center " , " value " : " $numero $ " , " icon-after " : " <?php echo (count( $preventivo->revisioni ) > 1) ? tr('rev.').' '. $preventivo->numero_revision : ''; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
2021-09-07 18:34:34 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data bozza'); ?> " , " name " : " data_bozza " , " required " : 1 , " value " : " $data_bozza $ " ]}
2019-07-24 12:42:45 +02:00
</ div >
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data accettazione'); ?> " , " name " : " data_accettazione " , " value " : " $data_accettazione $ " ]}
</ div >
< div class = " col-md-2 " >
2020-07-07 18:07:56 +02:00
{[ " type " : " date " , " label " : " <?php echo tr('Data conclusione'); ?> " , " name " : " data_conclusione " , " value " : " $data_conclusione $ " , " disabled " : " <?php echo $preventivo->isDataConclusioneAutomatica () ? '1 " , " help " : " '.tr('La Data di conclusione è calcolata in automatico in base al valore del campo Validità') : 0; ?> " ]}
2019-07-24 12:42:45 +02:00
</ div >
< div class = " col-md-2 " >
{[ " type " : " date " , " label " : " <?php echo tr('Data rifiuto'); ?> " , " name " : " data_rifiuto " , " value " : " $data_rifiuto $ " ]}
</ div >
2019-04-08 18:50:28 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2020-07-31 14:25:50 +02:00
< ? php
echo '
2019-04-08 18:50:28 +02:00
< div class = " row " >
2019-07-24 12:42:45 +02:00
< div class = " col-md-3 " >
2020-07-31 14:25:50 +02:00
'.Modules::link(' Anagrafiche ', $record[' idanagrafica '], null, null, ' class = " pull-right " ').'
{[ " type " : " select " , " label " : " '.tr('Cliente').' " , " name " : " idanagrafica " , " required " : 1 , " value " : " $idanagrafica $ " , " ajax-source " : " clienti " ]}
2019-07-24 12:42:45 +02:00
</ div >
< div class = " col-md-3 " >
2020-07-31 14:25:50 +02:00
{[ " type " : " select " , " label " : " '.tr('Sede').' " , " name " : " idsede " , " value " : " $idsede $ " , " ajax-source " : " sedi " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " placeholder " : " Sede legale " ]}
2019-07-24 12:42:45 +02:00
</ div >
2020-07-31 14:25:50 +02:00
< div class = " col-md-3 " > ' ;
2024-01-15 15:30:45 +01:00
if ( ! empty ( $record [ 'idreferente' ])) {
echo Plugins :: link ( 'Referenti' , $record [ 'idanagrafica' ], null , null , 'class="pull-right"' );
}
echo '
2023-01-13 09:35:27 +01:00
{[ " type " : " select " , " label " : " '.tr('Referente').' " , " name " : " idreferente " , " value " : " $idreferente $ " , " ajax-source " : " referenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' , " idsede_destinazione " : '.$record[' idsede '].' } ]}
2019-04-08 18:50:28 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2020-07-31 16:13:24 +02:00
< div class = " col-md-3 " > ' ;
2024-01-15 15:30:45 +01:00
if ( $record [ 'idagente' ] != 0 ) {
echo Modules :: link ( 'Anagrafiche' , $record [ 'idagente' ], null , null , 'class="pull-right"' );
}
2020-07-31 16:13:24 +02:00
echo '
2022-05-18 16:36:22 +02:00
{[ " type " : " select " , " label " : " '.tr('Agente').' " , " name " : " idagente " , " ajax-source " : " agenti " , " select-options " : { " idanagrafica " : '.$record[' idanagrafica '].' }, " value " : " $idagente $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2020-07-31 16:13:24 +02:00
</ div > ' ;
2024-01-15 15:30:45 +01:00
?>
2017-08-04 16:28:16 +02:00
2019-07-24 12:42:45 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Nome'); ?> " , " name " : " nome " , " required " : 1 , " value " : " $nome $ " ]}
</ div >
< div class = " col-md-3 " >
2020-11-06 10:46:42 +01:00
< ? php
2024-01-15 15:30:45 +01:00
if ( ! empty ( $record [ 'idpagamento' ])) {
echo Modules :: link ( 'Pagamenti' , $record [ 'idpagamento' ], null , null , 'class="pull-right"' );
}
?>
2020-11-04 18:31:43 +01:00
2024-02-15 16:52:46 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Pagamento'); ?> " , " name " : " idpagamento " , " values " : " query=SELECT `co_pagamenti`.`id`, `name` AS descrizione FROM `co_pagamenti` LEFT JOIN `co_pagamenti_lang` ON (`co_pagamenti`.`id` = `co_pagamenti_lang`.`id_record` AND `co_pagamenti_lang`.`id_lang` = <?php echo prepare(setting('Lingua')); ?>) GROUP BY `name` ORDER BY `name` " , " value " : " $idpagamento $ " ]}
2019-07-24 12:42:45 +02:00
</ div >
< div class = " col-md-3 " >
2023-09-27 17:04:00 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Stato'); ?> " , " name " : " idstato " , " required " : 1 , " values " : " query=SELECT id, descrizione, colore AS _bgcolor_ FROM co_statipreventivi ORDER BY descrizione " , " value " : " $idstato $ " , " class " : " unblockable " ]}
2019-07-24 12:42:45 +02:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< div class = " row " >
2019-04-08 18:50:28 +02:00
< div class = " col-md-3 " >
2020-07-07 18:07:56 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Validità offerta'); ?> " , " name " : " validita " , " decimals " : " 0 " , " value " : " $validita $ " , " icon-after " : " choice|period|<?php echo $record['tipo_validita'] ; ?> " , " help " : " <?php echo tr('Il campo Validità viene utilizzato in modo esclusivamente indicativo se impostato secondo l \ 'opzione manuale, mentre viene utilizzato per il calcolo della Data di conclusione del documento in caso alternativo'); ?> " ]}
2019-04-08 18:50:28 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2023-04-18 16:55:37 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Tipo di attività'); ?> " , " name " : " idtipointervento " , " required " : 1 , " ajax-source " : " tipiintervento " , " value " : " $idtipointervento $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-04-08 18:50:28 +02:00
<!-- div class = " col-md-3 " >
{[ " type " : " select " , " label " : " <?php echo tr('Resa materiale'); ?> " , " name " : " idporto " , " values " : " query=SELECT id, descrizione FROM dt_porto ORDER BY descrizione " , " value " : " $idporto $ " ]}
</ div -->
2019-11-29 18:21:31 +01:00
2017-08-04 16:28:16 +02:00
< div class = " col-md-3 " >
2019-04-08 18:50:28 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Tempi di consegna'); ?> " , " name " : " tempi_consegna " , " value " : " $tempi_consegna $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-11-29 18:21:31 +01:00
2021-04-06 15:10:55 +02:00
< div class = " col-md-3 " >
2022-01-15 17:30:49 +01:00
{[ " type " : " number " , " label " : " <?php echo 'Sconto in fattura'; ?> " , " name " : " sconto_finale " , " value " : " <?php echo $preventivo->sconto_finale_percentuale ?: $preventivo->sconto_finale ; ?> " , " icon-after " : " choice|untprc|<?php echo empty( $preventivo->sconto_finale ) ? 'PRC' : 'UNT'; ?> " , " help " : " <?php echo tr('Sconto in fattura, utilizzabile per applicare sconti sul netto a pagare del documento'); ?>. " ]}
2021-04-06 15:10:55 +02:00
</ div >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " row " >
2023-04-13 17:30:33 +02:00
< div class = " col-md-6 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Esclusioni'); ?> " , " name " : " esclusioni " , " class " : " autosize " , " value " : " $esclusioni $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2023-04-13 17:30:33 +02:00
< div class = " col-md-6 " >
2021-01-29 17:12:56 +01:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Garanzia'); ?> " , " name " : " garanzia " , " class " : " autosize " , " value " : " $garanzia $ " ]}
</ div >
</ div >
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Descrizione'); ?> " , " name " : " descrizione " , " class " : " autosize " , " value " : " $descrizione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2021-01-27 15:15:44 +01:00
< div class = " row " >
2023-11-08 12:33:43 +01:00
< div class = " col-md-12 " >
2023-08-04 14:54:28 +02:00
< ? php echo input ([
2024-01-15 15:30:45 +01:00
'type' => 'ckeditor' ,
'use_full_ckeditor' => 1 ,
'label' => tr ( 'Condizioni generali di fornitura' ),
'name' => 'condizioni_fornitura' ,
'value' => $record [ 'condizioni_fornitura' ],
]);
?>
2021-01-27 15:15:44 +01:00
</ div >
</ div >
2021-12-13 10:45:11 +01:00
< ? php
// Nascondo le note interne ai clienti
if ( $user -> gruppo != 'Clienti' ) {
echo '
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " textarea " , " label " : " '.tr('Note interne').' " , " name " : " informazioniaggiuntive " , " class " : " autosize " , " value " : " $informazioniaggiuntive $ " , " extra " : " rows= \ '5 \ ' " ]}
</ div >
</ div > ' ;
}
?>
2018-02-20 10:55:00 +01:00
<!-- div class = " pull-right " >
2017-09-04 12:02:29 +02:00
< button type = " submit " class = " btn btn-success " >< i class = " fa fa-check " ></ i > < ? php echo tr ( 'Salva modifiche' ); ?> </button>
2018-02-20 10:55:00 +01:00
</ div -->
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2019-11-29 18:21:31 +01:00
2019-10-14 19:13:11 +02:00
< ? php
2019-10-18 15:28:44 +02:00
if ( ! empty ( $record [ 'id_documento_fe' ]) || ! empty ( $record [ 'num_item' ]) || ! empty ( $record [ 'codice_cig' ]) || ! empty ( $record [ 'codice_cup' ])) {
2019-10-14 19:13:11 +02:00
$collapsed = '' ;
2022-07-03 15:19:20 +02:00
} else {
$collapsed = ' collapsed-box' ;
2019-10-14 19:13:11 +02:00
}
2024-01-15 15:30:45 +01:00
?>
2019-10-14 19:13:11 +02:00
<!-- Fatturazione Elettronica PA -->
2022-07-03 15:19:20 +02:00
< div class = " box box-primary collapsable <?php echo ( $record['tipo_anagrafica'] == 'Ente pubblico' || $record['tipo_anagrafica'] == 'Azienda') ? 'show' : 'hide'; ?> <?php echo $collapsed ; ?> " >
< div class = " box-header " >
< h4 class = " box-title " >
< ? php echo tr ( 'Dati appalto' ); ?> </h4>
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-plus " ></ i >
</ button >
</ div >
</ div >
< div class = " box-body " >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Identificatore Documento'); ?> " , " name " : " id_documento_fe " , " required " : 0 , " help " : " <?php echo tr('<span>Obbligatorio per valorizzare CIG/CUP. È possible inserire: </span><ul><li>N. determina</li><li>RDO</li><li>Ordine MEPA</li></ul>'); ?> " , " value " : " $id_documento_fe $ " , " maxlength " : 20 ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Numero Riga'); ?> " , " name " : " num_item " , " required " : 0 , " value " : " $num_item $ " , " maxlength " : 15 ]}
</ div >
2019-10-14 19:13:11 +02:00
</ div >
2022-07-03 15:19:20 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CIG'); ?> " , " name " : " codice_cig " , " required " : 0 , " value " : " $codice_cig $ " , " maxlength " : 15 ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice CUP'); ?> " , " name " : " codice_cup " , " required " : 0 , " value " : " $codice_cup $ " , " maxlength " : 15 ]}
2019-10-14 19:13:11 +02:00
</ div >
2019-01-24 20:31:01 +01:00
</ div >
</ div >
</ div >
2017-08-04 16:28:16 +02:00
</ form >
2020-08-03 12:08:52 +02:00
< ? php
2017-08-04 16:28:16 +02:00
2020-08-03 12:08:52 +02:00
echo '
2017-08-04 16:28:16 +02:00
<!-- RIGHE -->
< div class = " panel panel-primary " >
< div class = " panel-heading " >
2020-08-03 12:08:52 +02:00
< h3 class = " panel-title " > '.tr(' Righe ').' </ h3 >
2017-08-04 16:28:16 +02:00
</ div >
2020-08-03 12:08:52 +02:00
< div class = " panel-body " > ' ;
2019-03-29 12:46:17 +01:00
2019-07-24 12:42:45 +02:00
if ( ! $block_edit ) {
2023-02-17 10:59:50 +01:00
// Form di inserimento riga documento
2019-03-29 12:46:17 +01:00
echo '
2023-02-17 10:59:50 +01:00
< form id = " link_form " action = " " method = " post " >
< input type = " hidden " name = " op " value = " add_articolo " >
< input type = " hidden " name = " backto " value = " record-edit " >
2018-01-18 19:03:06 +01:00
2023-02-17 10:59:50 +01:00
< div class = " row " >
2023-05-24 17:15:29 +02:00
< div class = " col-md-3 " >
2023-02-17 10:59:50 +01:00
{[ " type " : " text " , " label " : " '.tr('Aggiungi un articolo tramite barcode').' " , " name " : " barcode " , " extra " : " autocomplete= \" off \" " , " icon-before " : " <i class= \" fa fa-barcode \" ></i> " , " required " : 0 ]}
</ div >
2018-01-18 19:03:06 +01:00
2023-02-17 10:59:50 +01:00
< div class = " col-md-4 " >
2023-02-28 17:00:21 +01:00
{[ " type " : " select " , " label " : " '.tr('Articolo').' " , " name " : " id_articolo " , " value " : " " , " ajax-source " : " articoli " , " select-options " : { " permetti_movimento_a_zero " : 1 }, " icon-after " : " add|'.Modules::get('Articoli')['id'].' " ]}
2023-02-17 10:59:50 +01:00
</ div >
2018-02-19 11:25:56 +01:00
2023-05-24 17:15:29 +02:00
< div class = " col-md-3 " style = " margin-top: 25px " >
2023-02-17 10:59:50 +01:00
< button title = " '.tr('Aggiungi articolo alla vendita').' " class = " btn btn-primary tip " type = " button " onclick = " salvaArticolo() " >
< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').'
</ button >
< a class = " btn btn-primary " onclick = " gestioneRiga(this) " data - title = " '.tr('Aggiungi riga').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Riga ').'
</ a >
< div class = " btn-group tip " data - toggle = " tooltip " >
< button type = " button " class = " btn btn-primary dropdown-toggle " data - toggle = " dropdown " aria - haspopup = " true " aria - expanded = " true " >
< i class = " fa fa-list " ></ i > '.tr(' Altro ').'
< span class = " caret " ></ span >
</ button >
< ul class = " dropdown-menu dropdown-menu-right " >
< li >
< a style = " cursor:pointer " onclick = " gestioneDescrizione(this) " data - title = " '.tr('Aggiungi descrizione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Descrizione ').'
</ a >
</ li >
< li >
< a style = " cursor:pointer " onclick = " gestioneSconto(this) " data - title = " '.tr('Aggiungi sconto/maggiorazione').' " >
< i class = " fa fa-plus " ></ i > '.tr(' Sconto / maggiorazione ').'
</ a >
</ li >
</ ul >
</ div >
</ div >
2023-05-24 17:15:29 +02:00
< div class = " col-md-2 " >
{[ " type " : " select " , " label " : " '.tr('Ordinamento').' " , " name " : " ordinamento " , " class " : " no-search " , " value " : " '.( $_SESSION['module_'.$id_module] ['order_row_desc'] ? 'desc' : 'manuale').' " , " values " : " list= \" desc \" : \" '.tr('Ultima riga inserita').' \" , \" manuale \" : \" '.tr('Manuale').' \" " ]}
</ div >
2023-02-17 10:59:50 +01:00
</ div >
</ form > ' ;
2019-03-29 12:46:17 +01:00
}
2018-01-18 19:03:06 +01:00
2020-08-03 12:08:52 +02:00
echo '
2018-02-21 09:53:38 +01:00
2017-08-04 16:28:16 +02:00
< div class = " clearfix " ></ div >
< br >
< div class = " row " >
2020-09-14 10:49:23 +02:00
< div class = " col-md-12 " id = " righe " ></ div >
</ div >
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2020-08-03 12:08:52 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
{( " name " : " log_email " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2018-11-09 11:34:27 +01:00
< script type = " text/javascript " >
2020-08-03 12:08:52 +02:00
function gestioneSconto ( button ) {
gestioneRiga ( button , " is_sconto " );
}
function gestioneDescrizione ( button ) {
gestioneRiga ( button , " is_descrizione " );
}
async function gestioneRiga ( button , options ) {
// Salvataggio via AJAX
2021-03-29 18:31:23 +02:00
await salvaForm ( " #edit-form " , {}, button );
// Lettura titolo e chiusura tooltip
2023-02-17 10:59:50 +01:00
let title = $ ( button ) . attr ( " data-title " );
2020-08-03 12:08:52 +02:00
// Apertura modal
2021-03-29 18:31:23 +02:00
options = options ? options : " is_riga " ;
openModal ( title , " '. $structure->fileurl ('row-add.php').'?id_module='. $id_module .'&id_record='. $id_record .'& " + options );
2020-08-03 12:08:52 +02:00
}
2020-09-14 10:49:23 +02:00
/**
* Funzione dedicata al caricamento dinamico via AJAX delle righe del documento .
*/
2023-02-17 10:59:50 +01:00
function caricaRighe ( id_riga ) {
2020-09-14 10:49:23 +02:00
let container = $ ( " #righe " );
localLoading ( container , true );
2020-09-14 11:06:35 +02:00
return $ . get ( " '. $structure->fileurl ('row-list.php').'?id_module='. $id_module .'&id_record='. $id_record .' " , function ( data ) {
container . html ( data );
2020-09-14 10:49:23 +02:00
localLoading ( container , false );
2023-02-17 10:59:50 +01:00
if ( id_riga != null ) {
$ ( " tr[data-id= " + id_riga + " ] " ) . effect ( " highlight " , 1000 );
}
2020-09-14 10:49:23 +02:00
});
}
$ ( document ) . ready ( function () {
2023-02-17 10:59:50 +01:00
caricaRighe ( null );
2020-08-03 12:08:52 +02:00
$ ( " #idanagrafica " ) . change ( function () {
updateSelectOption ( " idanagrafica " , $ ( this ) . val ());
session_set ( " superselect,idanagrafica " , $ ( this ) . val (), 0 );
$ ( " #idsede " ) . selectReset ();
2022-07-07 17:28:18 +02:00
$ ( " #idpagamento " ) . selectReset ();
let data = $ ( this ) . selectData ();
if ( data ) {
// Impostazione del tipo di pagamento da anagrafica
if ( data . id_pagamento ) {
input ( " idpagamento " ) . getElement ()
. selectSetNew ( data . id_pagamento , data . desc_pagamento );
}
}
2020-08-03 12:08:52 +02:00
});
$ ( " #data_accettazione " ) . on ( " dp.change " , function () {
if ( $ ( this ) . val ()){
$ ( " #data_rifiuto " ) . attr ( " disabled " , true );
} else {
$ ( " #data_rifiuto " ) . attr ( " disabled " , false );
}
});
2019-11-29 18:21:31 +01:00
2020-08-03 12:08:52 +02:00
$ ( " #data_rifiuto " ) . on ( " dp.change " , function () {
if ( $ ( this ) . val ()){
$ ( " #data_accettazione " ) . attr ( " disabled " , true );
} else {
$ ( " #data_accettazione " ) . attr ( " disabled " , false );
}
2018-11-09 11:34:27 +01:00
});
2017-09-14 10:27:49 +02:00
2020-08-03 12:08:52 +02:00
$ ( " #data_accettazione " ) . trigger ( " dp.change " );
$ ( " #data_rifiuto " ) . trigger ( " dp.change " );
2018-12-07 10:47:44 +01:00
2020-08-03 12:08:52 +02:00
$ ( " #codice_cig, #codice_cup " ) . bind ( " keyup change " , function ( e ) {
2018-12-07 10:47:44 +01:00
2020-08-03 12:08:52 +02:00
if ( $ ( " #codice_cig " ) . val () == " " && $ ( " #codice_cup " ) . val () == " " ){
$ ( " #id_documento_fe " ) . prop ( " required " , false );
} else {
$ ( " #id_documento_fe " ) . prop ( " required " , true );
}
2018-12-07 10:47:44 +01:00
2020-08-03 12:08:52 +02:00
});
2023-02-17 10:59:50 +01:00
$ ( " #id_articolo " ) . on ( " change " , function ( e ) {
if ( $ ( this ) . val ()) {
var data = $ ( this ) . selectData ();
if ( data . barcode ) {
$ ( " #barcode " ) . val ( data . barcode );
} else {
$ ( " #barcode " ) . val ( " " );
}
}
e . preventDefault ();
setTimeout ( function (){
$ ( " #barcode " ) . focus ();
}, 100 );
});
$ ( " #barcode " ) . focus ();
});
2023-03-30 16:36:24 +02:00
async function salvaArticolo () {
// Salvataggio via AJAX
await salvaForm ( " #edit-form " );
2023-02-17 10:59:50 +01:00
$ ( " #link_form " ) . ajaxSubmit ({
url : globals . rootdir + " /actions.php " ,
data : {
id_module : globals . id_module ,
id_record : globals . id_record ,
ajax : true ,
},
type : " post " ,
beforeSubmit : function ( arr , $form , options ) {
return $form . parsley () . validate ();
},
success : function ( response ){
renderMessages ();
if ( response . length > 0 ){
response = JSON . parse ( response );
swal ({
type : " error " ,
title : " '.tr('Errore').' " ,
text : response . error ,
});
}
$ ( " #barcode " ) . val ( " " );
$ ( " #id_articolo " ) . selectReset ();
2023-04-06 13:11:38 +02:00
content_was_modified = false ;
2023-02-17 10:59:50 +01:00
caricaRighe ( null );
}
});
}
2023-02-27 12:09:59 +01:00
$ ( " #link_form " ) . bind ( " keypress " , function ( e ) {
2023-02-17 10:59:50 +01:00
if ( e . keyCode == 13 ) {
e . preventDefault ();
salvaArticolo ();
return false ;
}
2020-08-03 12:08:52 +02:00
});
</ script > ' ;
2018-12-07 10:47:44 +01:00
2021-07-28 11:50:02 +02:00
// Fatture, ordini collegate a questo preventivo
$elementi = $dbo -> fetchArray ( 'SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento`.`descrizione` AS tipo_documento, IF(`co_tipidocumento`.`dir` = \'entrata\', \'Fatture di vendita\', \'Fatture di acquisto\') AS modulo FROM `co_documenti` JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` WHERE `co_documenti`.`id` IN (SELECT `iddocumento` FROM `co_righe_documenti` WHERE `idpreventivo` = ' . prepare ( $id_record ) . ' )
2018-12-07 10:47:44 +01:00
UNION
2022-04-01 10:23:09 +02:00
SELECT `or_ordini` . `id` , `or_ordini` . `data` , `or_ordini` . `numero` , `or_ordini` . `numero_esterno` , `or_tipiordine` . `descrizione` , IF ( `or_tipiordine` . `dir` = \ 'entrata\', \'Ordini cliente\', \'Ordini fornitore\') FROM `or_ordini` JOIN `or_righe_ordini` ON `or_righe_ordini`.`idordine` = `or_ordini`.`id` JOIN `or_tipiordine` ON `or_tipiordine`.`id` = `or_ordini`.`idtipoordine` WHERE `or_righe_ordini`.`idpreventivo` = ' . prepare ( $id_record ) . '
2021-07-28 11:50:02 +02:00
2023-11-08 12:33:43 +01:00
UNION
SELECT `dt_ddt` . `id` , `dt_ddt` . `data` , `dt_ddt` . `numero` , `dt_ddt` . `numero_esterno` , `dt_tipiddt` . `descrizione` , IF ( `dt_tipiddt` . `dir` = \ 'entrata\', \'Ddt di vendita\', \'Ddt di acquisto\') FROM `dt_ddt` JOIN `dt_righe_ddt` ON `dt_righe_ddt`.`idddt` = `dt_ddt`.`id` JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `dt_righe_ddt`.`original_document_id` = ' . prepare ( $preventivo -> id ) . ' AND `dt_righe_ddt` . `original_document_type` = \ ' Modules\\\\Preventivi\\\\Preventivo\ '
2021-07-28 11:50:02 +02:00
UNION
SELECT `in_interventi` . `id` , `in_interventi` . `data_richiesta` , `in_interventi` . `codice` , NULL , \ 'Attività\', \'Interventi\' FROM `in_interventi` JOIN `in_righe_interventi` ON `in_righe_interventi`.`idintervento` = `in_interventi`.`id` WHERE (`in_righe_interventi`.`original_document_id` = ' . prepare ( $preventivo -> id ) . ' AND `in_righe_interventi`.`original_document_type` = ' . prepare ( get_class ( $preventivo )) . ') OR `in_interventi`.`id_preventivo` = ' . prepare ( $id_record ) . '
2018-12-07 10:47:44 +01:00
ORDER BY `data` ' );
2018-09-05 10:05:23 +02:00
if ( ! empty ( $elementi )) {
2017-09-14 10:27:49 +02:00
echo '
2018-09-05 10:05:23 +02:00
< div class = " box box-warning collapsable collapsed-box " >
< div class = " box-header with-border " >
< h3 class = " box-title " >< i class = " fa fa-warning " ></ i > '.tr(' Documenti collegati : _NUM_ ' , [
2018-09-19 09:57:30 +02:00
'_NUM_' => count ( $elementi ),
2018-09-05 10:05:23 +02:00
]) . ' </ h3 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >< i class = " fa fa-plus " ></ i ></ button >
</ div >
</ div >
< div class = " box-body " >
< ul > ' ;
2018-12-07 10:47:44 +01:00
foreach ( $elementi as $elemento ) {
2017-09-14 10:27:49 +02:00
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
2018-12-07 10:47:44 +01:00
'_DOC_' => $elemento [ 'tipo_documento' ],
'_NUM_' => ! empty ( $elemento [ 'numero_esterno' ]) ? $elemento [ 'numero_esterno' ] : $elemento [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $elemento [ 'data' ]),
2017-09-14 10:27:49 +02:00
]);
2018-12-23 14:01:59 +01:00
2017-09-14 10:27:49 +02:00
echo '
2021-07-28 11:50:02 +02:00
< li > '.Modules::link($elemento[' modulo '], $elemento[' id '], $descrizione).' </ li > ' ;
2017-09-14 10:27:49 +02:00
}
echo '
</ ul >
2018-09-05 10:05:23 +02:00
</ div >
</ div > ' ;
}
if ( ! empty ( $elementi )) {
echo '
< div class = " alert alert-error " >
'.tr(' Eliminando questo documento si potrebbero verificare problemi nelle altre sezioni del gestionale ').' .
</ div > ' ;
2017-09-14 10:27:49 +02:00
}
2017-11-16 14:27:43 +01:00
?>
< a class = " btn btn-danger ask " data - backto = " record-list " >
2023-09-28 16:08:45 +02:00
< i id = " elimina " class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2018-01-15 20:28:36 +01:00
</ a >
2023-01-13 09:35:27 +01:00
< script >
2023-05-24 17:15:29 +02:00
$ ( " #idsede " ) . change ( function (){
updateSelectOption ( " idsede_destinazione " , $ ( this ) . val ());
$ ( " #idreferente " ) . selectReset ();
});
2023-01-13 09:35:27 +01:00
2023-05-24 17:15:29 +02:00
input ( " ordinamento " ) . on ( " change " , function (){
if ( input ( this ) . get () == " desc " ) {
session_set ( " module_<?php echo $id_module ; ?>,order_row_desc " , 1 , " " ) . then ( function () {
caricaRighe ( null );
});
} else {
session_set ( " module_<?php echo $id_module ; ?>,order_row_desc " ) . then ( function () {
caricaRighe ( null );
});
}
});
2023-01-13 09:35:27 +01:00
</ script >