2018-02-19 10:52:42 +01:00
< ? php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager : il software gestionale open source per l ' assistenza tecnica e la fatturazione
* Copyright ( C ) DevCode s . n . c .
*
* 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-19 10:52:42 +01:00
// Descrizione
echo App :: internalLoad ( 'descrizione.php' , $result , $options );
2018-09-03 16:31:15 +02:00
// Conti, rivalsa INPS e ritenuta d'acconto
echo App :: internalLoad ( 'conti.php' , $result , $options );
2018-02-19 10:52:42 +01:00
// Iva
echo '
< div class = " row " >
2020-04-21 15:44:49 +02:00
< div class = " col-md-4 '.(!empty( $options['nascondi_prezzi'] ) ? 'hidden' : '').' " >
2020-08-17 16:25:01 +02:00
{[ " type " : " select " , " label " : " '.tr('Iva').' " , " name " : " idiva " , " required " : 1 , " value " : " '. $result['idiva'] .' " , " ajax-source " : " iva " , " select-options " : '.json_encode($options[' select - options '][' iva ']).' ]}
2018-02-19 10:52:42 +01:00
</ div > ' ;
// Quantità
echo '
< div class = " col-md-4 " >
2020-09-08 14:45:48 +02:00
{[ " type " : " number " , " label " : " '.tr('Q.tà').' " , " name " : " qta " , " required " : 1 , " value " : " '. $result['qta'] .' " , " decimals " : " qta " '.(isset($result[' max_qta ']) ? ' , " icon-after " : " <span class= \" tip \" title= \" '.tr( " L 'elemento è collegato a un documento: la quantità massima ammessa è relativa allo stato di evasione dell' elemento nel documento di origine ( quantità dell 'elemento / quantità massima ammessa)").' \ " >/ '.numberFormat( $result['max_qta'] , 'qta').' <i class= \" fa fa-question-circle-o \" ></i></span> " ' : ' ').' , " min-value " : " '. $result['qta_evasa'] .' " ]}
2018-02-19 10:52:42 +01:00
</ div > ' ;
// Unità di misura
echo '
< div class = " col-md-4 " >
{[ " type " : " select " , " label " : " '.tr('Unità di misura').' " , " icon-after " : " add|'.Modules::get('Unità di misura')['id'].' " , " name " : " um " , " value " : " '. $result['um'] .' " , " ajax-source " : " misure " ]}
2018-02-19 11:25:56 +01:00
</ div >
</ div > ' ;
2018-02-19 10:52:42 +01:00
echo '
2020-04-20 18:33:43 +02:00
< div class = " row '.(!empty( $options['nascondi_prezzi'] ) ? 'hidden' : '').' " > ' ;
2019-04-19 18:32:29 +02:00
2018-12-24 10:46:59 +01:00
$width = $options [ 'dir' ] == 'entrata' ? 4 : 6 ;
$label = $options [ 'dir' ] == 'entrata' ? tr ( 'Prezzo unitario di vendita' ) : tr ( 'Prezzo unitario' );
2019-04-19 18:32:29 +02:00
2018-12-23 16:16:59 +01:00
if ( $options [ 'dir' ] == 'entrata' ) {
// Prezzo di acquisto unitario
echo '
< div class = " col-md-'. $width .' " >
2020-02-14 18:31:07 +01:00
{[ " type " : " number " , " label " : " '.tr('Prezzo unitario di acquisto').' " , " name " : " costo_unitario " , " value " : " '. $result['costo_unitario'] .' " , " icon-after " : " '.currency().' " ]}
2018-12-23 14:25:20 +01:00
</ div > ' ;
2018-12-23 16:16:59 +01:00
// Funzione per l'aggiornamento in tempo reale del guadagno
echo '
< script >
function aggiorna_guadagno () {
2020-02-14 18:31:07 +01:00
var costo_unitario = $ ( " #costo_unitario " ) . val () . toEnglish ();
var prezzo = $ ( " #prezzo_unitario " ) . val () . toEnglish ();
2018-12-23 16:16:59 +01:00
var sconto = $ ( " #sconto " ) . val () . toEnglish ();
if ( $ ( " #tipo_sconto " ) . val () === " PRC " ) {
2018-12-24 10:46:59 +01:00
sconto = sconto / 100 * prezzo ;
2018-12-23 16:16:59 +01:00
}
2020-02-14 18:31:07 +01:00
var guadagno = prezzo - sconto - costo_unitario ;
2020-07-03 16:28:11 +02:00
var margine = ((( prezzo - sconto ) * 100 ) / costo_unitario ) - 100 ;
2020-02-14 18:31:07 +01:00
var parent = $ ( " #costo_unitario " ) . closest ( " div " ) . parent ();
2018-12-23 16:16:59 +01:00
var div = parent . find ( " div[id*= \" errors \" ] " );
2020-07-06 13:57:45 +02:00
margine = isNaN ( margine ) || ! isFinite ( margine ) ? 0 : margine ; // Fix per magine NaN
2020-10-15 18:33:06 +02:00
div . html ( " <small> '.tr('Guadagno').': " + guadagno . toLocale () + " " + globals . currency + " '.tr('Margine').': " + margine . toLocale () + " %</small> " );
2018-12-23 16:16:59 +01:00
if ( guadagno < 0 ) {
parent . addClass ( " has-error " );
2020-10-15 18:33:06 +02:00
div . addClass ( " label-danger " ) . removeClass ( " label-success " );
2018-12-23 16:16:59 +01:00
} else {
parent . removeClass ( " has-error " );
2020-10-15 18:33:06 +02:00
div . removeClass ( " label-danger " ) . addClass ( " label-success " );
2018-12-23 16:16:59 +01:00
}
}
aggiorna_guadagno ();
2018-12-24 10:46:59 +01:00
2020-02-14 18:31:07 +01:00
$ ( " #prezzo_unitario " ) . keyup ( aggiorna_guadagno );
$ ( " #costo_unitario " ) . keyup ( aggiorna_guadagno );
2018-12-25 11:32:19 +01:00
$ ( " #sconto " ) . keyup ( aggiorna_guadagno );
$ ( " #tipo_sconto " ) . change ( aggiorna_guadagno );
2018-12-23 16:16:59 +01:00
</ script > ' ;
}
2018-12-23 14:25:20 +01:00
// Prezzo di vendita unitario
echo '
2018-12-23 16:16:59 +01:00
< div class = " col-md-'. $width .' " >
2020-02-28 00:22:12 +01:00
{[ " type " : " number " , " label " : " '. $label .' " , " name " : " prezzo_unitario " , " value " : " '. $result['prezzo_unitario_corrente'] .' " , " required " : 1 , " icon-after " : " '.currency().' " , " help " : " '.( $options['dir'] == 'entrata' && setting('Utilizza prezzi di vendita comprensivi di IVA') ? tr('Importo IVA inclusa') : '').' " ]}
2018-02-19 10:52:42 +01:00
</ div > ' ;
// Sconto unitario
echo '
2018-12-23 16:16:59 +01:00
< div class = " col-md-'. $width .' " >
2020-02-15 14:11:44 +01:00
{[ " type " : " number " , " label " : " '.tr('Sconto unitario').' " , " name " : " sconto " , " value " : " '.( $result['sconto_percentuale'] ?: $result['sconto_unitario_corrente'] ).' " , " icon-after " : " choice|untprc|'. $result['tipo_sconto'] .' " , " help " : " '.tr('Il valore positivo indica uno sconto. Per applicare una maggiorazione inserire un valore negativo.').' " ]}
2018-02-19 10:52:42 +01:00
</ div >
</ div > ' ;
2020-08-06 11:36:43 +02:00
// Data prevista evasione (per ordini)
2020-08-06 11:44:41 +02:00
if ( in_array ( $module [ 'name' ], [ 'Ordini cliente' , 'Ordini fornitore' ])) {
2020-10-07 14:54:18 +02:00
if ( $options [ 'action' ] == 'add' ){
if ( $options [ 'dir' ] == 'entrata' ){
$confermato = setting ( " Conferma automaticamente le quantità negli ordini cliente " );
}
else {
$confermato = setting ( " Conferma automaticamente le quantità negli ordini fornitore " );
}
}
else {
$confermato = $result [ 'confermato' ];
}
2020-08-06 11:36:43 +02:00
echo '
2020-08-06 11:44:41 +02:00
< div class = " box box-warning collapsable collapsed-box " >
< div class = " box-header with-border " >
< h3 class = " box-title " > '.tr(' Informazioni aggiuntive ').' </ 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 >
2020-08-06 11:36:43 +02:00
</ div >
2020-08-06 11:44:41 +02:00
</ div >
< div class = " box-body " >
< div class = " row " >
2020-10-07 14:54:18 +02:00
< div class = " col-md-4 " >
2020-08-06 11:44:41 +02:00
{[ " type " : " date " , " label " : " '.tr('Data prevista evasione').' " , " name " : " data_evasione " , " value " : " '. $result['data_evasione'] .' " ]}
</ div >
2020-10-14 15:40:47 +02:00
< div class = " col-md-4 " >
2020-10-15 12:06:21 +02:00
{[ " type " : " checkbox " , " label " : " '.tr('Cambia data a tutte le righe').' " , " name " : " data_evasione_all " , " value " : " " ]}
2020-10-14 15:40:47 +02:00
</ div >
</ div >
< div class = " row " >
2020-10-07 14:54:18 +02:00
< div class = " col-md-4 " >
{[ " type " : " checkbox " , " label " : " '.tr('Articolo confermato').' " , " name " : " confermato " , " value " : " '. $confermato .' " ]}
2020-10-06 12:25:22 +02:00
</ div >
2020-10-14 15:40:47 +02:00
< div class = " col-md-4 " >
2020-10-15 12:06:21 +02:00
{[ " type " : " checkbox " , " label " : " '.tr('Cambia stato a tutte le righe').' " , " name " : " confermato_all " , " value " : " " ]}
2020-10-14 15:40:47 +02:00
</ div >
2020-08-06 11:44:41 +02:00
</ div >
</ div >
</ div > ' ;
2020-08-06 11:36:43 +02:00
}