|
92 | 92 |
|
93 | 93 | echo json_encode([ |
94 | 94 | 'id' => $index + 1, |
| 95 | + 'name' => $file, |
95 | 96 | ]); |
96 | 97 |
|
97 | 98 | break; |
|
124 | 125 |
|
125 | 126 | case 'generate': |
126 | 127 | $filename = post('filename'); |
| 128 | + $fattura_pa = FatturaElettronica::manage($filename); |
127 | 129 |
|
128 | | - $info = [ |
129 | | - 'id_pagamento' => post('pagamento'), |
130 | | - 'id_segment' => post('id_segment'), |
131 | | - 'id_tipo' => post('id_tipo'), |
132 | | - 'ref_fattura' => post('ref_fattura'), |
133 | | - 'data_registrazione' => post('data_registrazione'), |
134 | | - 'articoli' => post('articoli'), |
135 | | - 'iva' => post('iva'), |
136 | | - 'conto' => post('conto'), |
137 | | - 'tipo_riga_riferimento' => post('tipo_riga_riferimento'), |
138 | | - 'id_riga_riferimento' => post('id_riga_riferimento'), |
139 | | - 'tipo_riga_riferimento_vendita' => post('tipo_riga_riferimento_vendita'), |
140 | | - 'id_riga_riferimento_vendita' => post('id_riga_riferimento_vendita'), |
141 | | - 'movimentazione' => post('movimentazione'), |
142 | | - 'crea_articoli' => post('crea_articoli'), |
143 | | - 'is_ritenuta_pagata' => post('is_ritenuta_pagata'), |
144 | | - 'update_info' => post('update_info'), |
145 | | - 'serial' => post('flag_crea_seriali') ? post('serial') : [], |
146 | | - ]; |
| 130 | + if (post('type') == 'auto') { |
| 131 | + $info = FatturaElettronica::getInfoAutoImportFE($fattura_pa); |
| 132 | + } else { |
| 133 | + $info = [ |
| 134 | + 'id_pagamento' => post('pagamento'), |
| 135 | + 'id_segment' => post('id_segment'), |
| 136 | + 'id_tipo' => post('id_tipo'), |
| 137 | + 'ref_fattura' => post('ref_fattura'), |
| 138 | + 'data_registrazione' => post('data_registrazione'), |
| 139 | + 'articoli' => post('articoli'), |
| 140 | + 'iva' => post('iva'), |
| 141 | + 'conto' => post('conto'), |
| 142 | + 'tipo_riga_riferimento' => post('tipo_riga_riferimento'), |
| 143 | + 'id_riga_riferimento' => post('id_riga_riferimento'), |
| 144 | + 'tipo_riga_riferimento_vendita' => post('tipo_riga_riferimento_vendita'), |
| 145 | + 'id_riga_riferimento_vendita' => post('id_riga_riferimento_vendita'), |
| 146 | + 'movimentazione' => post('movimentazione'), |
| 147 | + 'crea_articoli' => post('crea_articoli'), |
| 148 | + 'is_ritenuta_pagata' => post('is_ritenuta_pagata'), |
| 149 | + 'update_info' => post('update_info'), |
| 150 | + 'serial' => post('flag_crea_seriali') ? post('serial') : [], |
| 151 | + ]; |
| 152 | + } |
147 | 153 |
|
148 | | - $fattura_pa = FatturaElettronica::manage($filename); |
149 | 154 | $id_fattura = $fattura_pa->save($info, 'Fornitore'); |
150 | 155 | $fattura_pa->delete(); |
151 | 156 | $fattura = Fattura::find($id_fattura); |
|
196 | 201 | } |
197 | 202 | } |
198 | 203 |
|
199 | | - $files = Interaction::getFileList(); |
200 | | - $file = $files[$id_record - 1]; |
201 | | - |
202 | 204 | if (get('sequence') == null) { |
203 | | - redirect_url(base_path_osm().'/editor.php?id_module='.$id_module.'&id_record='.$id_fattura); |
204 | | - } elseif (!empty($file)) { |
205 | | - redirect_url(base_path_osm().'/editor.php?id_module='.$id_module.'&id_plugin='.$id_plugin.'&id_record='.$id_record.'&sequence=1'); |
206 | | - flash()->info(tr('La fattura numero _NUM_ del _DATA_ (_ANAGRAFICA_) è stata importata correttamente', [ |
| 205 | + flash()->info(tr('La fattura numero _NUM_ del _DATA_ è stata importata correttamente', [ |
207 | 206 | '_NUM_' => $fattura->numero, |
208 | 207 | '_DATA_' => dateFormat($fattura->data), |
209 | | - '_ANAGRAFICA_' => $fattura->anagrafica->ragione_sociale, |
210 | 208 | ])); |
| 209 | + redirect_url(base_path_osm().'/editor.php?id_module='.$id_module.'&id_record='.$id_fattura); |
211 | 210 | } else { |
212 | | - flash()->info(tr('Tutte le fatture salvate sono state importate!')); |
213 | | - redirect_url(base_path_osm().'/controller.php?id_module='.$id_module); |
| 211 | + $files = Interaction::getFileList(); |
| 212 | + $file = $files[$id_record - 1]; |
| 213 | + if (!empty($file)) { |
| 214 | + redirect_url(base_path_osm().'/editor.php?id_module='.$id_module.'&id_plugin='.$id_plugin.'&id_record='.$id_record.'&sequence=1'); |
| 215 | + flash()->info(tr('La fattura numero _NUM_ del _DATA_ (_ANAGRAFICA_) è stata importata correttamente', [ |
| 216 | + '_NUM_' => $fattura->numero, |
| 217 | + '_DATA_' => dateFormat($fattura->data), |
| 218 | + '_ANAGRAFICA_' => $fattura->anagrafica->ragione_sociale, |
| 219 | + ])); |
| 220 | + } else { |
| 221 | + flash()->info(tr('Tutte le fatture salvate sono state importate!')); |
| 222 | + redirect_url(base_path_osm().'/controller.php?id_module='.$id_module); |
| 223 | + } |
214 | 224 | } |
215 | 225 | break; |
216 | 226 |
|
|
0 commit comments