BUB-22 Creato importazione documenti csv da Cassa Rurale
This commit is contained in:
@@ -271,7 +271,6 @@ class MovimentiController extends Controller
|
||||
if ($request->hasFile('filename'))
|
||||
{
|
||||
$filename=$request->file('filename')->store('EC');
|
||||
// dd($filename); Documenti/xyz.xls
|
||||
Movimenti::importEstrattoIng($filename);
|
||||
|
||||
return redirect(Route('movimenti'));
|
||||
@@ -282,10 +281,30 @@ class MovimentiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function importEC_CR(Request $request)
|
||||
{
|
||||
if ($request->hasFile('filename'))
|
||||
{
|
||||
$filename=$request->file('filename')->store('EC');
|
||||
Movimenti::importEstrattoCR($filename);
|
||||
|
||||
return redirect(Route('movimenti'));
|
||||
}
|
||||
else {
|
||||
return 'Nessun File trovato';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function importFile()
|
||||
{
|
||||
return view('conti.import');
|
||||
}
|
||||
|
||||
public function importFileCR()
|
||||
{
|
||||
return view('conti.importCR');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -166,6 +166,45 @@ class Movimenti extends Model
|
||||
//dd($outputPath);
|
||||
}
|
||||
|
||||
public static function importEstrattoCR($filename)
|
||||
{
|
||||
//$file = str_replace('/EC/','',$filename);
|
||||
$inputPath='/var/www/html/bubofamily/public/storage/'.$filename;
|
||||
$outputPath='/var/www/html/bubofamily/public/'.$filename.'.csv';
|
||||
rename($inputPath,$outputPath);
|
||||
|
||||
$collection = (new FastExcel)->configureCsv(';')->import($filename.'.csv', function ($line){
|
||||
if($line['VALUTA'])
|
||||
{
|
||||
if($line['DARE']<>'')
|
||||
{
|
||||
$dati=[
|
||||
'mov_data'=>Movimenti::dateFormat(0,$line['VALUTA']),
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
|
||||
'mov_importo'=>'-'.trim(str_replace(',','.',(str_replace('.','',$line['DARE'])))),
|
||||
'mov_fk_tags'=>1,
|
||||
'userid'=>1,
|
||||
];
|
||||
}
|
||||
if($line['AVERE']<>'')
|
||||
{
|
||||
$dati=[
|
||||
'mov_data'=>Movimenti::dateFormat(0,$line['VALUTA']),
|
||||
'mov_fk_categoria'=>1,
|
||||
'mov_descrizione'=>$line['DESCRIZIONE OPERAZIONE'],
|
||||
'mov_importo'=>trim(str_replace(',','.',(str_replace('.','',$line['AVERE'])))),
|
||||
'mov_fk_tags'=>1,
|
||||
'userid'=>1,
|
||||
];
|
||||
}
|
||||
Movimenti::insEntrata($dati);
|
||||
// dd($dati);
|
||||
}
|
||||
|
||||
});
|
||||
//dd($outputPath);
|
||||
}
|
||||
private static function dateFormat($type,$string)
|
||||
{
|
||||
if($type)
|
||||
|
||||
Reference in New Issue
Block a user