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-23 15:39:00 +02:00
use Modules\DDT\DDT ;
use Modules\Fatture\Fattura ;
2017-08-04 16:28:16 +02:00
2019-07-23 15:39:00 +02:00
$documento_finale = Fattura :: find ( $id_record );
$dir = $documento_finale -> direzione ;
$id_documento = get ( 'id_documento' );
if ( ! empty ( $id_documento )) {
$documento = DDT :: find ( $id_documento );
2019-02-14 17:49:58 +01:00
$options = [
2019-07-23 15:39:00 +02:00
'op' => 'add_documento' ,
'type' => 'ddt' ,
'serials' => true ,
2019-02-14 17:49:58 +01:00
'button' => tr ( 'Aggiungi' ),
2019-07-23 15:39:00 +02:00
'documento' => $documento ,
'documento_finale' => $documento_finale ,
2020-09-24 11:36:47 +02:00
'tipo_documento_finale' => Fattura :: class ,
2021-07-07 13:01:54 +02:00
'superamento_soglia_qta' => setting ( 'Permetti il superamento della soglia quantità dei documenti di origine' ),
2019-02-14 17:49:58 +01:00
];
2019-07-23 15:39:00 +02:00
echo App :: load ( 'importa.php' , [], $options , true );
2019-02-14 17:49:58 +01:00
return ;
2017-08-04 16:28:16 +02:00
}
2019-07-23 15:39:00 +02:00
$id_anagrafica = $documento_finale -> idanagrafica ;
2017-08-04 16:28:16 +02:00
echo '
2019-02-14 17:49:58 +01:00
< div class = " row " >
< div class = " col-md-12 " >
2024-05-03 12:15:09 +02:00
{[ " type " : " select " , " label " : " '.tr('Ddt').' " , " name " : " id_documento " , " values " : " query=SELECT `dt_ddt`.`id`, CONCAT( \ 'DDT num. \ ', IF(`numero_esterno` != \ ' \ ', `numero_esterno`, `numero`), \ ' del \ ', DATE_FORMAT(`data`, \ '%d-%m-%Y \ '), \ ' [ \ ', `dt_statiddt_lang`.`title`, \ '] \ ') AS descrizione FROM `dt_ddt` LEFT JOIN `dt_causalet` ON `dt_causalet`.`id` = `dt_ddt`.`idcausalet` INNER JOIN `dt_statiddt` ON `dt_ddt`.`idstatoddt` = `dt_statiddt`.`id` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang` = '.prepare(Models \ Locale::getDefault()->id).') INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` INNER JOIN `dt_righe_ddt ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` WHERE `idanagrafica`='.prepare( $id_anagrafica ).' AND `dt_statiddt_lang`.`title` IN( " Evaso " , " Parzialmente evaso " , " Parzialmente fatturato " ) AND `dt_tipiddt`.`dir`='.prepare( $dir ).' AND `dt_causalet`.`is_importabile` = 1 AND (`dt_righe_ddt`.`qta` - `dt_righe_ddt`.`qta_evasa`) > 0 ORDER BY `data` DESC, `numero` DESC " ]}
2019-02-14 17:49:58 +01:00
</ div >
</ div >
2017-08-04 16:28:16 +02:00
2019-07-23 15:39:00 +02:00
< div id = " righe_documento " >
2020-07-14 13:30:25 +02:00
2019-02-14 17:49:58 +01:00
</ div >
2017-08-04 16:28:16 +02:00
2019-02-14 17:49:58 +01:00
< div class = " alert alert-info " id = " box-loading " >
< i class = " fa fa-spinner fa-spin " ></ i > '.tr(' Caricamento in corso ').' ...
</ div > ' ;
2017-08-04 16:28:16 +02:00
2019-02-14 17:49:58 +01:00
$file = basename ( __FILE__ );
echo '
2019-07-26 18:05:19 +02:00
< script > $ ( document ) . ready ( init ) </ script >
2020-07-14 13:30:25 +02:00
2017-08-04 16:28:16 +02:00
< script >
2019-02-14 17:49:58 +01:00
var content = $ ( " #righe_documento " );
var loader = $ ( " #box-loading " );
2020-07-14 13:30:25 +02:00
2020-07-31 14:25:50 +02:00
$ ( document ) . ready ( function () {
2019-02-14 17:49:58 +01:00
loader . hide ();
2019-07-23 15:39:00 +02:00
});
2020-07-14 13:30:25 +02:00
2020-07-31 14:25:50 +02:00
$ ( " #id_documento " ) . on ( " change " , function () {
2019-02-14 17:49:58 +01:00
loader . show ();
2017-08-04 16:28:16 +02:00
2019-02-14 17:49:58 +01:00
var id = $ ( this ) . selectData () ? $ ( this ) . selectData () . id : " " ;
2020-07-14 13:30:25 +02:00
2019-07-23 15:39:00 +02:00
content . html ( " " );
content . load ( " '. $structure->fileurl ( $file ).'?id_module='. $id_module .'&id_record='. $id_record .'&id_documento= " + id , function () {
2019-02-14 17:49:58 +01:00
loader . hide ();
});
2017-08-04 16:28:16 +02:00
});
2019-02-14 17:49:58 +01:00
</ script > ' ;