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' ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2024-03-22 15:52:24 +01:00
use Modules\Iva\Aliquota ;
2022-03-07 09:35:58 +01:00
2018-02-23 16:04:50 +01:00
?> <form action="" method="post" id="edit-form" enctype="multipart/form-data">
2017-08-04 16:28:16 +02:00
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " op " value = " update " >
<!-- DATI ANAGRAFICI -->
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >< ? php echo tr ( 'Articolo' ); ?> </h3>
2017-08-04 16:28:16 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-3 " >
2020-05-04 09:45:48 +02:00
{[ " type " : " image " , " label " : " <?php echo tr('Immagine'); ?> " , " name " : " immagine " , " class " : " img-thumbnail " , " value " : " <?php echo $articolo->image ; ?> " , " accept " : " image/x-png,image/gif,image/jpeg " ]}
2017-08-04 16:28:16 +02:00
</ div >
2019-11-08 14:58:49 +01:00
< div class = " col-md-9 " >
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " text " , " label " : " <?php echo tr('Codice'); ?> " , " name " : " codice " , " required " : 1 , " value " : " $codice $ " , " validation " : " codice " ]}
</ div >
2019-11-19 18:06:10 +01:00
< div class = " col-md-6 " >
2024-07-29 16:49:47 +02:00
{[ " type " : " text " , " label " : " <?php echo tr('Barcode'); ?> " , " name " : " barcode " , " value " : " $barcode $ " ]}
2019-12-03 20:16:43 +01:00
</ div >
2019-11-08 14:58:49 +01:00
</ div >
< div class = " row " >
< div class = " col-md-6 " >
2023-08-04 14:54:28 +02:00
< ? php echo ( ! empty ( $record [ 'id_categoria' ])) ?
Modules :: link ( 'Categorie articoli' , $record [ 'id_categoria' ], null , null , 'class="pull-right"' ) : '' ; ?>
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Categoria'); ?> " , " name " : " categoria " , " required " : 0 , " value " : " $id_categoria $ " , " ajax-source " : " categorie " , " icon-after " : " add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?> " ]}
2019-11-08 14:58:49 +01:00
</ div >
< div class = " col-md-6 " >
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Sottocategoria'); ?> " , " name " : " subcategoria " , " value " : " $id_sottocategoria $ " , " ajax-source " : " sottocategorie " , " select-options " : < ? php echo json_encode ([ 'id_categoria' => $record [ 'id_categoria' ]]); ?> , "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]}
2019-11-08 14:58:49 +01:00
</ div >
</ div >
2018-04-04 00:13:26 +02:00
</ div >
2017-08-04 16:28:16 +02:00
</ div >
2020-07-06 13:32:43 +02:00
2017-08-04 16:28:16 +02:00
< div class = " row " >
< div class = " col-md-12 " >
2024-09-06 09:59:51 +02:00
< ? php
echo input ([
'type' => 'textarea' ,
'label' => tr ( 'Descrizione' ),
'name' => 'descrizione' ,
'required' => 1 ,
'value' => $articolo -> getTranslation ( 'title' ),
2024-09-10 12:38:16 +02:00
'charcounter' => 1 ,
]);
?>
2017-08-04 16:28:16 +02:00
</ div >
</ div >
2020-07-06 13:32:43 +02:00
2020-02-01 11:02:23 +01:00
< div class = " row " >
2020-11-13 17:54:58 +01:00
< div class = " col-md-6 " >
2020-02-01 11:02:23 +01:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Abilita serial number'); ?> " , " name " : " abilita_serial " , " value " : " $abilita_serial $ " , " help " : " <?php echo tr('Abilita serial number in fase di aggiunta articolo in fattura o ddt'); ?> " , " placeholder " : " <?php echo tr('Serial number'); ?> " , " extra " : " <?php echo ( $record['serial'] > 0) ? 'readonly' : ''; ?> " ]}
</ div >
2020-11-13 17:54:58 +01:00
< div class = " col-md-6 " >
2020-02-01 11:02:23 +01:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Attivo'); ?> " , " name " : " attivo " , " help " : " <?php echo tr('Seleziona per rendere attivo l \ 'articolo'); ?> " , " value " : " $attivo $ " , " placeholder " : " <?php echo tr('Articolo attivo'); ?> " ]}
</ div >
2017-08-04 16:28:16 +02:00
2020-02-01 11:02:23 +01:00
</ div >
2020-07-08 08:45:55 +02:00
2020-11-13 17:54:58 +01:00
< div class = " row " >
< div class = " col-md-8 " >
{[ " type " : " text " , " label " : " <?php echo tr('Ubicazione'); ?> " , " name " : " ubicazione " , " value " : " $ubicazione $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
2020-11-13 17:54:58 +01:00
< div class = " col-md-4 " >
2024-06-11 16:58:27 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Unità di misura'); ?> " , " name " : " um " , " value " : " $um $ " , " ajax-source " : " misure " , " icon-after " : " add|<?php echo Module::where('name', 'Unità di misura')->first()->id; ?> " ]}
2017-08-04 16:28:16 +02:00
</ div >
2020-02-01 11:02:23 +01:00
</ div >
2017-08-04 16:28:16 +02:00
2020-11-13 17:54:58 +01:00
< div class = " row " >
2017-08-04 16:28:16 +02:00
< div class = " col-md-12 " >
2017-09-04 12:02:29 +02:00
{[ " type " : " textarea " , " label " : " <?php echo tr('Note'); ?> " , " name " : " note " , " value " : " $note $ " ]}
2017-08-04 16:28:16 +02:00
</ div >
</ div >
</ div >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >
2020-11-13 17:54:58 +01:00
< ? php echo tr ( 'Giacenza totale' ); ?>
</ h3 >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2020-11-13 17:54:58 +01:00
< div class = " row " >
< div class = " col-md-6 " >
2023-08-04 14:54:28 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Quantità'); ?> " , " name " : " qta " , " required " : 1 , " value " : " $qta $ " , " readonly " : 1 , " decimals " : " qta " , " min-value " : " undefined " , " icon-after " : " <?php echo !empty( $record['um'] ) ? $record['um'] : ''; ?> " ]}
2020-11-13 17:54:58 +01:00
< input type = " hidden " id = " old_qta " value = " <?php echo $record['qta'] ; ?> " >
</ div >
< div class = " col-md-6 " >
{[ " type " : " checkbox " , " label " : " <?php echo tr('Modifica quantità'); ?> " , " name " : " qta_manuale " , " value " : 0 , " help " : " <?php echo tr('Seleziona per modificare manualmente la quantità'); ?> " , " placeholder " : " <?php echo tr('Quantità manuale'); ?> " , " extra " : " <?php echo ( $record['servizio'] ) ? 'disabled' : ''; ?> " ]}
</ div >
</ div >
< div class = 'row' id = " div_modifica_manuale " style = " display:none; " >
< div class = 'col-md-8' >
{[ " type " : " text " , " label " : " <?php echo tr('Descrizione movimento'); ?> " , " name " : " descrizione_movimento " ]}
</ div >
< div class = 'col-md-4' >
{[ " type " : " date " , " label " : " <?php echo tr('Data movimento'); ?> " , " name " : " data_movimento " , " value " : " -now- " ]}
</ div >
</ div >
< div class = " alert alert-info " >
2022-08-04 22:05:28 +02:00
< p >< ? php echo tr ( 'Le modifiche alle quantità in questa schermata prevedono la generazione di un movimento relativo alla sede legale' ); ?> . <?php echo tr('Se si desidera effettuare movimenti per altre sedi, utilizzare il modulo _MODULO_ ', [
2023-08-04 14:54:28 +02:00
'_MODULO_' => Modules :: link ( 'Movimenti' , null , tr ( 'Movimenti' )),
2022-08-04 22:05:28 +02:00
]); ?> .</p>
2020-11-13 17:54:58 +01:00
</ div >
< script type = " text/javascript " >
$ ( document ) . ready ( function () {
$ ( '#servizio' ) . click ( function () {
$ ( " #qta_manuale " ) . attr ( " disabled " , $ ( '#servizio' ) . is ( " :checked " ));
});
$ ( '#qta_manuale' ) . click ( function () {
$ ( " #qta " ) . attr ( " readonly " , ! $ ( '#qta_manuale' ) . is ( " :checked " ));
if ( $ ( '#qta_manuale' ) . is ( " :checked " )){
$ ( " #div_modifica_manuale " ) . show ();
$ ( " #div_modifica_manuale " ) . show ();
$ ( " #descrizione_movimento " ) . attr ( 'required' , true );
$ ( " #data_movimento " ) . attr ( 'required' , true );
} else {
$ ( " #div_modifica_manuale " ) . hide ();
$ ( '#qta' ) . val ( $ ( '#old_qta' ) . val ());
$ ( " #descrizione_movimento " ) . attr ( 'required' , false );
$ ( " #data_movimento " ) . attr ( 'required' , false );
}
});
});
</ script >
</ div >
</ div >
2018-04-03 23:31:44 +02:00
<!-- informazioni Acquisto / Vendita -->
< div class = " row " >
< div class = " col-md-6 " >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >< ? php echo tr ( 'Acquisto' ); ?> </h3>
2018-04-03 23:31:44 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2018-04-03 23:31:44 +02:00
< div class = " row " >
2022-03-07 09:35:58 +01:00
< div class = " col-md-4 " >
2020-07-06 13:32:43 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Prezzo di acquisto'); ?> " , " name " : " prezzo_acquisto " , " value " : " $prezzo_acquisto $ " , " icon-after " : " <?php echo currency(); ?> " , " help " : " <?php echo tr('Prezzo di acquisto previsto per i fornitori i cui dati non sono stati inseriti nel plugin Fornitori'); ?>. " ]}
2018-04-03 23:31:44 +02:00
</ div >
2022-03-07 09:35:58 +01:00
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " <?php echo tr('Coefficiente di vendita'); ?> " , " name " : " coefficiente " , " value " : " $coefficiente $ " , " help " : " <?php echo tr('Imposta un coefficiente per calcolare automaticamente il prezzo di vendita quando cambia il prezzo di acquisto'); ?>. " ]}
</ div >
< div class = " col-md-4 " >
2018-04-03 23:31:44 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Soglia minima quantità'); ?> " , " name " : " threshold_qta " , " value " : " $threshold_qta $ " , " decimals " : " qta " , " min-value " : " undefined " ]}
</ div >
</ div >
2018-07-09 17:21:25 +02:00
2023-06-22 15:54:50 +02:00
< div class = " row " >
2019-11-12 18:45:52 +01:00
< div class = " col-md-12 " >
2023-08-04 14:54:28 +02:00
< ? php echo ( ! empty ( $record [ 'id_fornitore' ])) ?
2024-09-10 12:38:16 +02:00
Plugins :: link ( 'Listino Fornitori' , $id_record , null , null , 'class="pull-right" onclick="modificaFornitore(' . $id_record . ',' . $record [ 'id_fornitore' ] . ')"' ) : '' ; ?>
2021-10-26 10:18:32 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Fornitore predefinito'); ?> " , " name " : " id_fornitore " , " ajax-source " : " fornitori-articolo " , " select-options " : < ? php echo json_encode ([ 'id_articolo' => $id_record ]); ?> , "value":"$id_fornitore$", "help": "<?php echo tr('Fornitore predefinito selezionabile tra i fornitori presenti nel plugin \"Listino fornitori\"'); ?>." ]}
2019-11-12 18:45:52 +01:00
</ div >
</ div >
2018-07-09 17:21:25 +02:00
< div class = " row " >
< div class = " col-md-12 " >
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito di acquisto'); ?> " , " name " : " idconto_acquisto " , " value " : " $idconto_acquisto $ " , " ajax-source " : " conti-acquisti " ]}
</ div >
</ div >
2020-10-02 18:27:07 +02:00
< div class = " row " >
2020-11-05 16:37:47 +01:00
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " <?php echo tr('U.m. secondaria'); ?> " , " name " : " um_secondaria " , " value " : " $um_secondaria $ " , " ajax-source " : " misure " , " help " : " <?php echo tr( " Unità di misura da utilizzare nelle stampe di Ordini fornitori in relazione all ' articolo " ); ?> " ]}
2020-10-02 18:27:07 +02:00
</ div >
2020-11-05 16:37:47 +01:00
< div class = " col-md-4 " >
2023-03-03 18:21:09 +01:00
{[ " type " : " number " , " label " : " <?php echo tr('Fattore moltiplicativo'); ?> " , " name " : " fattore_um_secondaria " , " value " : " $fattore_um_secondaria $ " , " decimals " : " 10 " , " help " : " <?php echo tr( " Fattore moltiplicativo per l ' unità di misura da utilizzare nelle stampe di Ordini fornitori " ); ?> " ]}
2020-10-02 18:27:07 +02:00
</ div >
2020-11-05 16:37:47 +01:00
< div class = " col-md-4 " >
2021-05-14 14:29:49 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Q.tà multipla'); ?> " , " name " : " qta_multipla " , " value " : " $qta_multipla $ " , " decimals " : " qta " , " help " : " <?php echo tr('Quantità multipla di scorta da tenere a magazzino.'); ?> " ]}
2020-11-05 16:37:47 +01:00
</ div >
2020-10-02 18:27:07 +02:00
</ div >
2018-04-03 23:31:44 +02:00
</ div >
</ div >
</ div >
< div class = " col-md-6 " >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >
2019-03-01 16:41:24 +01:00
< ? php echo tr ( 'Vendita' ); ?>
</ h3 >
2018-04-03 23:31:44 +02:00
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2019-03-01 16:41:24 +01:00
< div class = " clearfix " ></ div >
2018-04-03 23:31:44 +02:00
< div class = " row " >
< div class = " col-md-6 " >
2020-02-17 09:44:09 +01:00
< ? php
2020-07-06 13:57:45 +02:00
$prezzi_ivati = setting ( 'Utilizza prezzi di vendita comprensivi di IVA' );
2022-03-07 09:35:58 +01:00
$iva_predefinita = setting ( 'Iva predefinita' );
$aliquota_predefinita = floatval ( Aliquota :: find ( $iva_predefinita ) -> percentuale );
2020-07-06 13:57:45 +02:00
if ( empty ( $prezzi_ivati )) {
2020-02-17 09:44:09 +01:00
echo '
2023-08-04 14:54:28 +02:00
< button type = " button " class = " btn btn-info btn-xs pull-right tip pull-right '.(!empty((int) $articolo->coefficiente ) ? 'disabled' : '').' " title = " '.tr('Scorpora l \ 'IVA dal prezzo di vendita.').' " id = " scorporaIva " >
2020-09-23 13:59:50 +02:00
< i class = " fa fa-calculator " ></ i >
</ button > ' ;
2020-02-17 09:44:09 +01:00
}
2020-07-06 13:57:45 +02:00
echo '
2023-08-04 14:54:28 +02:00
{[ " type " : " number " , " label " : " '.tr('Prezzo di vendita').' " , " name " : " prezzo_vendita " , " value " : " '.( $prezzi_ivati ? $articolo->prezzo_vendita_ivato : $articolo->prezzo_vendita ).' " , " icon-after " : " '.currency().' " , " help " : " '.( $prezzi_ivati ? tr('Importo IVA inclusa') : '').' " , " disabled " : " '.(!empty((int) $articolo->coefficiente ) ? 1 : 0).' " ]}
2020-07-06 13:57:45 +02:00
</ div > ' ;
?>
2018-04-03 23:31:44 +02:00
< div class = " col-md-6 " >
2022-01-04 15:05:14 +01:00
{[ " type " : " select " , " label " : " <?php echo tr('Iva di vendita'); ?> " , " name " : " idiva_vendita " , " ajax-source " : " iva " , " value " : " $idiva_vendita $ " , " help " : " <?php echo tr('Se non specificata, verrà utilizzata l \ 'iva di default delle impostazioni'); ?> " ]}
2022-03-07 09:35:58 +01:00
< input type = " hidden " name = " prezzi_ivati " value = " <?php echo $prezzi_ivati ; ?> " >
< input type = " hidden " name = " aliquota_predefinita " value = " <?php echo $aliquota_predefinita ; ?> " >
2018-04-03 23:31:44 +02:00
</ div >
</ div >
2018-04-04 00:13:26 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Garanzia'); ?> " , " name " : " gg_garanzia " , " decimals " : 0 , " value " : " $gg_garanzia $ " , " icon-after " : " GG " ]}
</ div >
< div class = " col-md-6 " >
2022-02-06 11:22:53 +01:00
{[ " type " : " checkbox " , " label " : " <?php echo tr('Questo articolo è un servizio'); ?> " , " name " : " servizio " , " value " : " $servizio $ " , " help " : " <?php echo tr('Le quantità non saranno considerate.'); ?> " , " placeholder " : " <?php echo tr('Servizio'); ?> " ]}
2018-04-04 00:13:26 +02:00
</ div >
</ div >
2018-05-05 09:29:09 +02:00
2018-04-04 00:13:26 +02:00
< div class = " row " >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Peso lordo'); ?> " , " name " : " peso_lordo " , " value " : " $peso_lordo $ " , " icon-after " : " KG " ]}
</ div >
< div class = " col-md-6 " >
{[ " type " : " number " , " label " : " <?php echo tr('Volume'); ?> " , " name " : " volume " , " value " : " $volume $ " , " icon-after " : " M<sup>3</sup> " ]}
</ div >
</ div >
2018-07-09 17:21:25 +02:00
< div class = " row " >
2022-11-15 17:38:42 +01:00
< div class = " col-md-6 " >
2018-07-09 17:21:25 +02:00
{[ " type " : " select " , " label " : " <?php echo tr('Conto predefinito di vendita'); ?> " , " name " : " idconto_vendita " , " value " : " $idconto_vendita $ " , " ajax-source " : " conti-vendite " ]}
</ div >
2022-11-15 17:38:42 +01:00
< div class = " col-md-6 " >
2023-08-04 14:54:28 +02:00
{[ " type " : " number " , " label " : " <?php echo tr('Minimo di vendita'); ?> " , " name " : " minimo_vendita " , " value " : " <?php echo $prezzi_ivati ? $articolo->minimo_vendita_ivato : $articolo->minimo_vendita ; ?> " , " icon-after " : " <?php echo currency(); ?> " , " help " : " <?php echo $prezzi_ivati ? tr('Importo IVA inclusa') : ''; ?> " ]}
2022-11-15 17:38:42 +01:00
</ div >
2018-07-09 17:21:25 +02:00
</ div >
2018-04-03 23:31:44 +02:00
</ div >
</ div >
</ div >
2021-12-17 13:36:12 +01:00
</ div >
< div class = " row " >
< div class = " col-md-6 " >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >
2021-12-17 13:36:12 +01:00
< ? php echo tr ( 'Ultimi 20 prezzi di acquisto' ); ?>
</ h3 >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2021-12-17 13:36:12 +01:00
< div class = " clearfix " ></ div >
< div class = " row " >
< div class = " col-md-12 " id = " prezziacquisto " ></ div >
</ div >
</ div >
</ div >
</ div >
< div class = " col-md-6 " >
2024-05-16 18:02:50 +02:00
< div class = " card card-primary " >
< div class = " card-header " >
< h3 class = " card-title " >
2021-12-17 13:36:12 +01:00
< ? php echo tr ( 'Ultimi 20 prezzi di vendita' ); ?>
</ h3 >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2021-12-17 13:36:12 +01:00
< div class = " clearfix " ></ div >
< div class = " row " >
< div class = " col-md-12 " id = " prezzivendita " ></ div >
</ div >
</ div >
</ div >
</ div >
2018-04-03 23:31:44 +02:00
</ div >
2021-08-31 15:46:14 +02:00
</ form >
2017-08-04 16:28:16 +02:00
2018-09-28 16:17:10 +02:00
{( " name " : " filelist_and_upload " , " id_module " : " $id_module $ " , " id_record " : " $id_record $ " )}
2018-05-17 14:33:40 +02:00
2017-08-04 16:28:16 +02:00
< script >
2022-03-07 09:35:58 +01:00
let iva_vendita = $ ( " #idiva_vendita " );
let percentuale = 0 ;
$ ( document ) . ready ( function () {
if ( iva_vendita . val ()) {
percentuale = parseFloat ( iva_vendita . selectData () . percentuale );
}
if ( ! percentuale ) {
percentuale = parseFloat ( input ( " aliquota_predefinita " ) . get ());
}
input ( " coefficiente " ) . on ( 'keyup' , function (){
if ( input ( " coefficiente " ) . get ()) {
let prezzo_vendita = input ( 'prezzo_acquisto' ) . get () * input ( " coefficiente " ) . get ();
if ( parseFloat ( input ( " prezzi_ivati " ) . get ())) {
prezzo_vendita = prezzo_vendita + ( prezzo_vendita * percentuale / 100 );
}
input ( " prezzo_vendita " ) . set ( prezzo_vendita );
input ( " prezzo_vendita " ) . disable ();
$ ( " #scorporaIva " ) . addClass ( " disabled " );
} else {
input ( " prezzo_vendita " ) . enable ();
$ ( " #scorporaIva " ) . removeClass ( " disabled " );
}
});
input ( " prezzo_acquisto " ) . on ( 'keyup change' , function (){
if ( input ( " coefficiente " ) . get ()) {
let prezzo_vendita = input ( 'prezzo_acquisto' ) . get () * input ( " coefficiente " ) . get ();
if ( parseFloat ( input ( " prezzi_ivati " ) . get ())) {
prezzo_vendita = prezzo_vendita + ( prezzo_vendita * percentuale / 100 );
}
input ( " prezzo_vendita " ) . set ( prezzo_vendita );
input ( " prezzo_vendita " ) . disable ();
$ ( " #scorporaIva " ) . addClass ( " disabled " );
} else {
input ( " prezzo_vendita " ) . enable ();
$ ( " #scorporaIva " ) . removeClass ( " disabled " );
}
});
});
2020-07-31 14:25:50 +02:00
$ ( " #categoria " ) . change ( function () {
2020-08-17 10:57:51 +02:00
updateSelectOption ( " id_categoria " , $ ( this ) . val ());
2017-08-04 16:28:16 +02:00
$ ( " #subcategoria " ) . val ( null ) . trigger ( " change " );
});
2019-03-01 16:41:24 +01:00
2020-09-23 13:59:50 +02:00
function scorporaIva () {
2022-03-07 09:35:58 +01:00
if ( ! percentuale ) return ;
let input = $ ( " #prezzo_vendita " );
let prezzo = input . val () . toEnglish ();
let scorporato = prezzo * 100 / ( 100 + percentuale );
input . val ( scorporato );
2019-03-01 16:41:24 +01:00
}
2019-03-01 18:04:07 +01:00
2020-09-23 13:59:50 +02:00
$ ( " #scorporaIva " ) . click ( function () {
scorporaIva ();
2019-10-01 18:01:00 +02:00
});
2017-08-04 16:28:16 +02:00
</ script >
2017-09-06 11:59:47 +02:00
< ? php
2018-09-05 10:05:23 +02:00
// Collegamenti diretti
// Fatture, ddt, preventivi collegati a questo articolo
2024-04-18 17:44:05 +02:00
$elementi = $dbo -> fetchArray ( 'SELECT `co_documenti`.`id`, `co_documenti`.`data`, `co_documenti`.`numero`, `co_documenti`.`numero_esterno`, `co_tipidocumento_lang`.`title` AS tipo_documento, `co_tipidocumento`.`dir`, SUM(`co_righe_documenti`.`qta`) AS qta_totale, ((SUM(`co_righe_documenti`.`prezzo_unitario`)-SUM(`co_righe_documenti`.`sconto_unitario`))*SUM(`co_righe_documenti`.`qta`)) AS prezzo_totale, SUM(`co_righe_documenti`.`prezzo_unitario`)-SUM(`co_righe_documenti`.`sconto_unitario`) AS prezzo_unitario FROM `co_documenti` INNER JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento` LEFT JOIN `co_tipidocumento_lang` ON (`co_tipidocumento_lang`.`id_record` = `co_tipidocumento`.`id` AND `co_tipidocumento_lang`.`id_lang` = ' . prepare ( Models\Locale :: getDefault () -> id ) . ') INNER JOIN `co_righe_documenti` ON `co_documenti`.`id`=`co_righe_documenti`.`iddocumento` WHERE `co_righe_documenti`.`idarticolo` = ' . prepare ( $id_record ) . ' GROUP BY `co_documenti` . `id`
2018-09-05 10:05:23 +02:00
2024-04-18 17:44:05 +02:00
UNION SELECT `dt_ddt` . `id` , `dt_ddt` . `data` , `dt_ddt` . `numero` , `dt_ddt` . `numero_esterno` , `dt_tipiddt_lang` . `title` AS tipo_documento , `dt_tipiddt` . `dir` , SUM ( dt_righe_ddt . qta ) AS qta_totale , (( SUM ( dt_righe_ddt . prezzo_unitario ) - SUM ( dt_righe_ddt . sconto_unitario )) * SUM ( dt_righe_ddt . qta )) AS prezzo_totale , SUM ( dt_righe_ddt . prezzo_unitario ) - SUM ( dt_righe_ddt . sconto_unitario ) AS prezzo_unitario FROM `dt_ddt` INNER JOIN `dt_tipiddt` ON `dt_tipiddt` . `id` = `dt_ddt` . `idtipoddt` LEFT JOIN `dt_tipiddt_lang` ON ( `dt_tipiddt_lang` . `id_record` = `dt_tipiddt` . `id` AND `dt_tipiddt_lang` . `id_lang` = '.prepare(Models\Locale::getDefault()->id).' ) INNER JOIN `dt_righe_ddt` ON `dt_ddt` . `id` = `dt_righe_ddt` . `idddt` WHERE `dt_righe_ddt` . `idarticolo` = '.prepare($id_record).' GROUP BY `dt_ddt` . `id`
2018-09-05 10:05:23 +02:00
2023-10-06 09:24:06 +02:00
UNION SELECT `co_preventivi` . `id` , `co_preventivi` . `data_bozza` , `co_preventivi` . `numero` , 0 AS numero_esterno , " Preventivo " AS tipo_documento , 0 AS dir , SUM ( co_righe_preventivi . qta ) AS qta_totale , (( SUM ( co_righe_preventivi . prezzo_unitario ) - SUM ( co_righe_preventivi . sconto_unitario )) * SUM ( co_righe_preventivi . qta )) AS prezzo_totale , SUM ( co_righe_preventivi . prezzo_unitario ) - SUM ( co_righe_preventivi . sconto_unitario ) AS prezzo_unitario FROM `co_preventivi` INNER JOIN `co_righe_preventivi` ON `co_preventivi` . `id` = `co_righe_preventivi` . `idpreventivo` WHERE `co_righe_preventivi` . `idarticolo` = '.prepare($id_record).' GROUP BY co_preventivi . id ORDER BY `data` ' );
2017-11-16 14:27:43 +01:00
if ( ! empty ( $elementi )) {
echo '
2024-05-16 18:02:50 +02:00
< div class = " card card-warning collapsable collapsed-card " >
< div class = " card-header with-border " >
< h3 class = " card-title " >< i class = " fa fa-warning " ></ i > '.tr(' Documenti collegati : _NUM_ ' , [
2024-03-22 15:52:24 +01:00
'_NUM_' => count ( $elementi ),
]) . ' </ h3 >
2024-05-16 18:02:50 +02:00
< 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 " >< i class = " fa fa-plus " ></ i ></ button >
2018-09-05 10:05:23 +02:00
</ div >
</ div >
2024-05-16 18:02:50 +02:00
< div class = " card-body " >
2022-01-14 16:25:58 +01:00
< table class = " table table-striped table-bordered table-extra-condensed " >
< tr >
< th > '.tr(' Documento ').' </ td >
< th width = " 12% " class = " text-center " > '.tr(' Quantità ').' </ td >
< th width = " 15% " class = " text-center " > '.tr(' Prezzo unitario ').' </ td >
< th width = " 15% " class = " text-center " > '.tr(' Prezzo totale ').' </ td >
< tr > ' ;
2017-11-16 14:27:43 +01:00
foreach ( $elementi as $elemento ) {
$descrizione = tr ( '_DOC_ num. _NUM_ del _DATE_' , [
'_DOC_' => $elemento [ 'tipo_documento' ],
'_NUM_' => ! empty ( $elemento [ 'numero_esterno' ]) ? $elemento [ 'numero_esterno' ] : $elemento [ 'numero' ],
'_DATE_' => Translator :: dateToLocale ( $elemento [ 'data' ]),
]);
2018-01-12 16:23:26 +01:00
2024-01-15 15:30:45 +01:00
// se non è un preventivo è un ddt o una fattura
// se non è un ddt è una fattura.
2018-01-12 16:23:26 +01:00
if ( in_array ( $elemento [ 'tipo_documento' ], [ 'Preventivo' ])) {
$modulo = 'Preventivi' ;
2024-06-13 09:31:40 +02:00
} elseif ( ! in_array ( $elemento [ 'tipo_documento' ], [ 'Ddt in uscita' , 'Ddt in entrata' , 'Ddt in entrata' , 'Ddt in uscita' ])) {
2018-01-12 16:23:26 +01:00
$modulo = ( $elemento [ 'dir' ] == 'entrata' ) ? 'Fatture di vendita' : 'Fatture di acquisto' ;
} else {
2024-06-13 09:31:40 +02:00
$modulo = ( $elemento [ 'dir' ] == 'entrata' ) ? 'Ddt in uscita' : 'Ddt in entrata' ;
2018-01-12 16:23:26 +01:00
}
2017-11-16 14:27:43 +01:00
$id = $elemento [ 'id' ];
echo '
2022-01-14 16:25:58 +01:00
< tr >
< td > '.Modules::link($modulo, $id, $descrizione).' </ td >
< td class = " text-center " > '.Translator::numberToLocale($elemento[' qta_totale ']).' </ td >
< td class = " text-right " > '.moneyFormat($elemento[' prezzo_unitario ']).' </ td >
< td class = " text-right " > '.moneyFormat($elemento[' prezzo_totale ']).' </ td >
< tr > ' ;
2017-11-16 14:27:43 +01:00
}
2017-09-06 11:59:47 +02:00
echo '
2022-01-14 16:25:58 +01:00
</ table >
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 > ' ;
2020-07-02 17:30:09 +02:00
}
?>
2017-11-16 14:27:43 +01:00
< a class = " btn btn-danger ask " data - backto = " record-list " >
< i class = " fa fa-trash " ></ i > < ? php echo tr ( 'Elimina' ); ?>
2020-07-06 13:57:45 +02:00
</ a >
2020-12-04 14:30:29 +01:00
< script >
input ( 'id_fornitore' ) . change ( function (){
2020-12-04 15:33:06 +01:00
let prezzo_unitario = $ ( this ) . selectData () ? $ ( this ) . selectData () . prezzo_unitario : " " ;
2020-12-04 14:30:29 +01:00
if ( input ( 'id_fornitore' ) . get ()){
input ( 'prezzo_acquisto' ) . set ( prezzo_unitario );
input ( 'prezzo_acquisto' ) . disable ();
} else {
input ( 'prezzo_acquisto' ) . enable ();
input ( 'prezzo_acquisto' ) . set ( '0' );
}
});
$ ( document ) . ready ( function (){
if ( input ( 'id_fornitore' ) . get ()){
input ( 'prezzo_acquisto' ) . disable ();
}
2021-12-17 13:36:12 +01:00
$ ( " #prezziacquisto " ) . load ( " <?php echo base_path(); ?>/ajax_complete.php?module=Articoli&op=getprezziacquisto&idarticolo= " + < ? php echo $id_record ; ?> + "&limit=20");
$ ( " #prezzivendita " ) . load ( " <?php echo base_path(); ?>/ajax_complete.php?module=Articoli&op=getprezzivendita&idarticolo= " + < ? php echo $id_record ; ?> + "&limit=20");
2020-12-04 14:30:29 +01:00
});
2020-12-04 15:33:06 +01:00
</ script >