forked from nathalie/pedi2
		
	
		
			
				
	
	
		
			48 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Http\Controllers;
 | |
| 
 | |
| use App\GrupoDeCompra;
 | |
| use Symfony\Component\HttpFoundation\BinaryFileResponse;
 | |
| 
 | |
| class AdminController extends Controller
 | |
| {
 | |
|     public function show()
 | |
|     {
 | |
|         return view('auth/login');
 | |
|     }
 | |
| 
 | |
|     public function index() {
 | |
|         return view('auth/admin_subpedidos');
 | |
|     }
 | |
| 
 | |
|     public function exportarPedidosAPdf(GrupoDeCompra $gdc) {
 | |
|         $gdc->exportarPedidosAPdf();
 | |
|     }
 | |
| 
 | |
|     public function exportarPedidoACSV(GrupoDeCompra $gdc): BinaryFileResponse
 | |
|     {
 | |
|         $gdc->exportarPedidoEnCSV();
 | |
|         $pattern = storage_path('csv/exports/'. $gdc->nombre . '-*.csv');
 | |
|         $files = glob($pattern);
 | |
| 
 | |
|         usort($files, function ($a, $b) {
 | |
|             return filemtime($b) <=> filemtime($a);
 | |
|         });
 | |
| 
 | |
|         return response()->download($files[0]);
 | |
|     }
 | |
| 
 | |
|     public function exportarPedidoConNucleosACSV(GrupoDeCompra $gdc): BinaryFileResponse
 | |
|     {
 | |
|         $gdc->exportarPedidoConNucleosEnCSV();
 | |
|         $pattern = storage_path('csv/exports/'.$gdc->nombre.'-completo-*.csv');
 | |
|         $files = glob($pattern);
 | |
| 
 | |
|         usort($files, function ($a, $b) {
 | |
|             return filemtime($b) <=> filemtime($a);
 | |
|         });
 | |
| 
 | |
|         return response()->download($files[0]);
 | |
|     }
 | |
| }
 |