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
* 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 />.
*/
2017-08-04 16:28:16 +02:00
include_once __DIR__ . '/../../../core.php' ;
// Movimentazione degli articoli
echo '
< div class = " box " >
< div class = " box-header with-border " >
2017-09-04 12:02:29 +02:00
< h3 class = " box-title " > '.tr(' Movimenti ').' </ h3 >
2020-03-03 10:33:32 +01:00
< div class = " pull-right " > ' ;
if ( empty ( $_GET [ 'movimentazione_completa' ])) {
echo '
< a class = " btn btn-info btn-xs " href = " '. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&movimentazione_completa=1#tab_'. $id_plugin .' " >
< i class = " fa fa-eye " ></ i >
'.tr(' Mostra tutti i movimenti ').'
</ a > ' ;
} else {
echo '
< a class = " btn btn-info btn-xs " href = " '. $rootdir .'/editor.php?id_module='. $id_module .'&id_record='. $id_record .'&movimentazione_completa=0#tab_'. $id_plugin .' " >
< i class = " fa fa-eye-slash " ></ i >
'.tr(' Mostra gli ultimi 20 movimenti ').'
</ a > ' ;
}
echo '
< a class = " btn btn-warning btn-xs " href = " '. $rootdir .'/controller.php?id_module='.Modules::get('Movimenti')->id.'&search_Articolo='.( $articolo->codice .' - '. $articolo->descrizione ).' " >
< i class = " fa fa-external-link " ></ i >
'.tr(' Visualizza dettagli ').'
</ a > ' ;
echo '
</ div >
2017-08-04 16:28:16 +02:00
</ div >
< div class = " box-body " > ' ;
// Calcolo la quantità dai movimenti in magazzino
2019-11-15 18:03:59 +01:00
$qta_totale = $dbo -> fetchOne ( 'SELECT SUM(qta) AS qta FROM mg_movimenti WHERE idarticolo=' . prepare ( $id_record ))[ 'qta' ];
$qta_totale_attuale = $dbo -> fetchOne ( 'SELECT SUM(qta) AS qta FROM mg_movimenti WHERE idarticolo=' . prepare ( $id_record ) . ' AND data <= CURDATE()' )[ 'qta' ];
2017-08-04 16:28:16 +02:00
2019-11-15 18:03:59 +01:00
echo '
2020-03-03 10:33:32 +01:00
< p > '.tr(' Quantità calcolata dai movimenti ').' : < b > '.Translator::numberToLocale($qta_totale, ' qta ').' '.$record[' um '].' </ b > < span class = " tip " title = " '.tr('Quantità calcolata da tutti i movimenti registrati').'. " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ p > ' ;
2017-08-04 16:28:16 +02:00
2019-11-15 18:03:59 +01:00
echo '
2020-03-03 10:33:32 +01:00
< p > '.tr(' Quantità calcolata attuale ').' : < b > '.Translator::numberToLocale($qta_totale_attuale, ' qta ').' '.$record[' um '].' </ b > < span class = " tip " title = " '.tr('Quantità calcolata secondo i movimenti registrati con data oggi o date trascorse').'. " >< i class = " fa fa-question-circle-o " ></ i ></ span ></ p > ' ;
2018-05-17 11:37:23 +02:00
2020-03-03 10:33:32 +01:00
// Individuazione movimenti
$movimenti = $articolo -> movimentiComposti ()
-> orderBy ( 'data' , 'id' );
if ( empty ( $_GET [ 'movimentazione_completa' ])) {
$movimenti -> limit ( 20 );
2017-08-04 16:28:16 +02:00
}
2020-03-03 10:33:32 +01:00
// Raggruppamento per documento
$movimenti = $movimenti -> get ();
2019-09-11 16:50:42 +02:00
if ( ! empty ( $movimenti )) {
2017-08-04 16:28:16 +02:00
echo '
< table class = " table table-striped table-condensed table-bordered " >
< tr >
2019-09-11 16:50:42 +02:00
< th class = " text-center " > '.tr(' Q . tà ').' </ th >
< th class = " text-center " > '.tr(' Q . tà progressiva ').' </ th >
2020-03-03 10:33:32 +01:00
< th > '.tr(' Operazione ').' </ th >
2019-09-11 16:50:42 +02:00
< th class = " text-center " > '.tr(' Data ').' </ th >
2018-05-17 12:58:53 +02:00
< th class = " text-center " width = " 7% " > #</th>
2017-08-04 16:28:16 +02:00
</ tr > ' ;
2019-09-11 16:50:42 +02:00
foreach ( $movimenti as $i => $movimento ) {
// Quantità progressiva
if ( $i == 0 ) {
$movimento [ 'progressivo_finale' ] = $articolo -> qta ;
} else {
$movimento [ 'progressivo_finale' ] = $movimenti [ $i - 1 ][ 'progressivo_iniziale' ];
}
2020-03-03 10:33:32 +01:00
$movimento [ 'progressivo_iniziale' ] = $movimento [ 'progressivo_finale' ] - $movimento -> qta ;
$movimento [ 'progressivo_iniziale' ] = $movimento [ 'progressivo_finale' ] - $movimento -> qta ;
2019-09-11 16:50:42 +02:00
$movimenti [ $i ][ 'progressivo_iniziale' ] = $movimento [ 'progressivo_iniziale' ];
$movimenti [ $i ][ 'progressivo_finale' ] = $movimento [ 'progressivo_finale' ];
2017-08-04 16:28:16 +02:00
// Quantità
echo '
< tr >
2019-09-11 16:50:42 +02:00
< td class = " text-center " >
2020-03-03 10:33:32 +01:00
'.numberFormat($movimento->qta, ' qta ').' '.$record[' um '].'
2019-09-11 16:50:42 +02:00
</ td >
2020-03-03 10:33:32 +01:00
2019-09-11 16:50:42 +02:00
< td class = " text-center " >
'.numberFormat($movimento[' progressivo_iniziale '], ' qta ').' '.$record[' um '].'
< i class = " fa fa-arrow-circle-right " ></ i >
'.numberFormat($movimento[' progressivo_finale '], ' qta ').' '.$record[' um '].'
2020-03-03 10:33:32 +01:00
</ td >
2018-07-03 17:28:02 +02:00
2020-03-03 10:33:32 +01:00
< td >
'.$movimento->descrizione.' '.($movimento->hasDocument() ? ' - '.reference($movimento->getDocument()) : ' ').'
</ td > ' ;
2017-08-04 16:28:16 +02:00
// Data
echo '
2020-03-03 10:33:32 +01:00
< td class = " text-center " > '.dateFormat($movimento->data).' < span class = " tip " title = " '.tr('Data di creazione del movimento: _DATE_', [
'_DATE_' => timestampFormat ( $movimento -> created_at ),
]) . '"><i class="fa fa-question-circle-o"></i></span> </td>' ;
2017-09-05 17:31:58 +02:00
// Operazioni
echo '
< td class = " text-center " > ' ;
2020-03-03 10:33:32 +01:00
if ( Auth :: admin () && $movimento -> isManuale ()) {
2017-09-05 17:31:58 +02:00
echo '
2020-03-03 10:33:32 +01:00
< a class = " btn btn-danger btn-xs ask " data - backto = " record-edit " data - op = " delmovimento " data - idmovimento = " '. $movimento['id'] .' " >
2017-09-05 17:31:58 +02:00
< i class = " fa fa-trash " ></ i >
</ a > ' ;
}
echo '
</ td >
2017-08-04 16:28:16 +02:00
</ tr > ' ;
}
2019-09-11 16:50:42 +02:00
2017-08-04 16:28:16 +02:00
echo '
</ table > ' ;
} else {
2018-06-26 14:30:26 +02:00
echo '
2018-05-17 12:58:53 +02:00
< div class = " alert alert-info " >
< i class = " fa fa-info-circle " ></ i >
2019-09-11 16:50:42 +02:00
'.tr(' Questo articolo non è ancora stato movimentato ').' .
2018-05-17 12:58:53 +02:00
</ div > ' ;
2017-08-04 16:28:16 +02:00
}
echo '
</ div >
</ div > ' ;