2023-11-30 12:57:03 +01:00
< ? php
include_once __DIR__ . '/../../core.php' ;
2024-03-05 16:01:45 +01:00
use Models\Module ;
2023-11-30 12:57:03 +01:00
$idautomezzo = get ( 'idautomezzo' );
$idarticolo = get ( 'idarticolo' );
2023-12-01 17:21:47 +01:00
$op = 'addrow' ;
2023-11-30 12:57:03 +01:00
$qta = 1 ;
2023-12-01 17:21:47 +01:00
if ( ! empty ( $idarticolo ) && ! empty ( $idautomezzo )) {
$qta = $dbo -> fetchOne ( 'SELECT SUM(mg_movimenti.qta) AS qta FROM mg_movimenti WHERE mg_movimenti.idarticolo=' . prepare ( $idarticolo ) . ' AND mg_movimenti.idsede=' . prepare ( $idautomezzo ))[ 'qta' ];
$op = 'editrow' ;
2023-11-30 12:57:03 +01:00
}
/*
Form di inserimento riga documento
*/
echo '
2024-03-05 16:01:45 +01:00
< form id = " link_form " action = " '. $rootdir .'/editor.php?id_module='.(new Module())->getByName('Automezzi')->id_record.'&id_record='. $idautomezzo .' " method = " post " >
2023-11-30 12:57:03 +01:00
< input type = " hidden " name = " op " value = " '. $op .' " >
< input type = " hidden " name = " backto " value = " record-edit " >
< input type = " hidden " name = " id_record " value = " '. $idautomezzo .' " > ' ;
// Seleziona articolo
echo '
< div class = " col-md-8 " >
2023-12-14 09:27:48 +01:00
{[ " type " : " select " , " label " : " '.tr('Articolo').' " , " name " : " idarticolo " , " required " : 1 , " value " : " '. $idarticolo .' " , " ajax-source " : " articoli " , " select-options " : '.json_encode([' idsede_partenza ' => 0]).' ]}
2023-11-30 12:57:03 +01:00
</ div > ' ;
// Quantità
echo '
< div class = " col-md-4 " >
{[ " type " : " number " , " label " : " '.tr('Q.tà su questo automezzo').' " , " name " : " qta " , " value " : " '. $qta .' " , " decimals " : " qta " ]}
</ div > ' ;
echo '
<!-- PULSANTI -->
< div class = " row " >
< div class = " col-md-12 text-right " >
< button type = " submit " class = " btn btn-primary pull-right " >< i class = " fa fa-plus " ></ i > '.tr(' Aggiungi ').' </ button >
</ div >
</ div >
</ form > ' ;
echo '
< script >
$ ( document ) . ready ( function (){ init ();});
</ script > ' ;