public function getEditar() { $user = User::find(session('id')); if (session('level') > 3) { $contribuyentes = Contribuyente::all(); } else { $contribuyentes = Contribuyente::where('user_id', '=', session('id'))->get(); } return view('contribuyentes.editar', compact('contribuyentes')); }
public function getIndex() { $id = session('id'); $carga = Cargas::where('user_id', '=', $id)->where('procesado', '=', false)->first(); if (!$carga) { $carga = Cargas::create(['user_id' => $id]); } if (session('level') > 3) { $contribuyentes = Contribuyente::all(); } else { $contribuyentes = Contribuyente::where('user_id', '=', session('id'))->get(); } $contri = $carga->contribuyente; $anio = $carga->anio; $mes = $carga->mes; return view('cargar.cargar', compact('contribuyentes', 'contri', 'anio', 'mes')); }
public function getIngresos(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); $ingresos = $diff->getIngresos(); $contr = Contribuyente::where('rfc', '=', $contr)->first(); $array = ['nombre' => $contr->nombre, 'rfc' => $contr->rfc, 'ingresos' => $ingresos]; Excel::create('Ingresos', function ($excel) use($array) { $excel->sheet('New sheet', function ($sheet) use($array) { $sheet->loadView('descargas.reporte-ingresos', $array); }); })->download('xlsx'); }