예제 #1
0
 public function getJust($idCarga)
 {
     $carga = Cargas::find($idCarga);
     if ($carga) {
         //obtener cargas
         $empresa = $carga->empresa()->orderBy('tipo_receptor')->get();
         $sat = $carga->sat()->orderBy('tipo_receptor')->get();
         $diff = new DiferenciasCFID($sat, $empresa, $carga->rfc);
         $just_emitidos = $diff->get_justificados_emitidos();
         $just_recibidos = $diff->get_justificados_recibidos();
         $array = ['rfc' => $carga->rfc, 'nombre' => $carga->contribuyente->nombre, 'justEm' => $just_emitidos, 'justRec' => $just_recibidos];
         $namePdf = $carga->rfc . "_" . time() . ".pdf";
         \PDF::loadView('descargas.reporte-justificados', $array)->save(storage_path('temp') . "/{$namePdf}");
         $nameZip = "just_" . time() . ".zip";
         $zipper = new Zipper();
         $zipper->make(storage_path("temp/{$nameZip}"))->add(storage_path('temp') . "/{$namePdf}");
         $anexos = $diff->getAnexos();
         foreach ($anexos as $anexo) {
             $zipper->folder($anexo['uuid']);
             foreach ($anexo['anexos'] as $file) {
                 $zipper->add($file->file);
             }
         }
         $zipper->close();
         return response()->download(storage_path("temp/{$nameZip}"), $nameZip);
     }
 }
예제 #2
0
 public function getJust(Request $request)
 {
     try {
         $contr = $request->cont;
         $desde = Carbon::createFromFormat('Y-m-d', $request->desde)->startOfDay();
         $hasta = Carbon::createFromFormat('Y-m-d', $request->hasta)->endOfDay();
     } catch (\Exception $e) {
         return view('vacio');
     }
     $sat = ArchivoSat::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) {
         $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr);
     })->get();
     $empresa = ArchivoEmpresa::whereBetween('fecha', array($desde, $hasta))->where(function ($q) use($contr) {
         $q->where('rfc_emisor', '=', $contr)->orWhere('rfc_receptor', '=', $contr);
     })->get();
     $todos = $sat->count() + $empresa->count();
     if ($todos == 0) {
         return view('vacio');
     }
     $diff = new DiferenciasCFID($sat, $empresa, $contr);
     $just_emitidos = $diff->get_justificados_emitidos();
     $just_recibidos = $diff->get_justificados_recibidos();
     $contr = Contribuyente::where('rfc', '=', $contr)->first();
     $array = ['nombre' => $contr->nombre, 'rfc' => $contr->rfc, 'justEm' => $just_emitidos, 'justRec' => $just_recibidos];
     $namePdf = $contr->rfc . "_" . time() . ".pdf";
     \PDF::loadView('descargas.reporte-justificados', $array)->save(storage_path('temp') . "/{$namePdf}");
     $nameZip = "just_" . time() . ".zip";
     $zipper = new Zipper();
     $zipper->make(storage_path("temp/{$nameZip}"))->add(storage_path('temp') . "/{$namePdf}");
     $anexos = $diff->getAnexos();
     foreach ($anexos as $anexo) {
         $zipper->folder($anexo['uuid']);
         foreach ($anexo['anexos'] as $file) {
             $zipper->add($file->file);
         }
     }
     $zipper->close();
     return response()->download(storage_path("temp/{$nameZip}"), $nameZip);
 }