diff --git a/app/Models/Movimenti.php b/app/Models/Movimenti.php index 363596b..6045c60 100644 --- a/app/Models/Movimenti.php +++ b/app/Models/Movimenti.php @@ -184,33 +184,43 @@ JOIN categories as c ON a.mov_fk_categoria=c.id'; public static function importEstrattoIng($filename) { $inputPath='/var/www/html/bubofamily/public/storage/'.$filename; - $outputPath='/var/www/html/bubofamily/public/'.$filename; + // $outputPath='/var/www/html/bubofamily/public/'.$filename.'.csv'; + $outputPath = $inputPath.'.csv'; rename($inputPath,$outputPath); - - $collection = (new FastExcel)->import($outputPath, function ($line){ + $collection = (new FastExcel)->configureCsv(";")->import($outputPath, function ($line){ if($line['DATA VALUTA']) { + if($line['ENTRATE']!=null) + { + $importo = $line['ENTRATE']; + } elseif($line['USCITE']!=null) + { + $importo = $line['USCITE']; + } + $euro=str_replace(',','.',str_replace('+','',str_replace('.','', $importo))); list($giorno,$mese,$anno) = explode('/',$line['DATA VALUTA']); $data="$anno-$mese-$giorno"; self::insEntrata([ 'mov_data'=>self::dateFormat(0,$line['DATA VALUTA']), 'mov_fk_categoria'=>1, 'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'], - 'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',str_replace('€', '', $line['IMPORTO IN EURO']))))), + 'mov_importo'=>$euro, 'mov_fk_tags'=>1, 'userid'=>1, ]); } - }); + }); + unlink($outputPath); } public static function importEstrattoCR($filename) { $inputPath='/var/www/html/bubofamily/public/storage/'.$filename; - $outputPath='/var/www/html/bubofamily/public/'.$filename.'.csv'; + // $outputPath='/var/www/html/bubofamily/public/'.$filename.'.csv'; + $outputPath = $inputPath.'.csv'; rename($inputPath,$outputPath); - $collection = (new FastExcel)->configureCsv(';')->import($filename.'.csv', function ($line){ + $collection = (new FastExcel)->configureCsv(';')->import($outputPath, function ($line){ if($line['VALUTA']) { if($line['DARE']<>'') @@ -241,6 +251,7 @@ JOIN categories as c ON a.mov_fk_categoria=c.id'; self::insEntrata($dati); } }); + unlink($outputPath); } public static function getYearsFromMovimenti()