From 00ffc0be22ab122e339ce75ffbcfe7dd08bdcb2a Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 14:07:01 -0600 Subject: [PATCH 1/6] Funcion para devolver el listado de contactos y instituciones --- app/Http/Controllers/ContactoController.php | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/Http/Controllers/ContactoController.php b/app/Http/Controllers/ContactoController.php index 9f895bc..d86522a 100644 --- a/app/Http/Controllers/ContactoController.php +++ b/app/Http/Controllers/ContactoController.php @@ -18,6 +18,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Str; use Illuminate\Support\Facades\Storage; +use Carbon\Carbon; class ContactoController extends Controller { @@ -662,4 +663,49 @@ public function upload(Request $request) return redirect()->route('contacto.get')->with('success', 'Importación de contactos almacenada correctamente'); } + + public function obtenerEventos(Request $request){ + $start = Carbon::parse($request->query('start')); + $end = Carbon::parse($request->query('end')); + + // Obtener cumpleaños en el rango de fechas visible + $cumpleanios = Contacto::where(function ($query) use ($start, $end) { + for ($date = $start->copy(); $date->lte($end); $date->addDay()) { + $query->orWhere(function ($subQuery) use ($date) { + $subQuery->where('mes_cump', $date->format('m')) + ->where('dia_cump', $date->format('d')); + }); + } + }) + ->select('id', 'nombre', 'ap_paterno', 'ap_materno', 'mes_cump', 'dia_cump') + ->get(); + + // Obtener aniversarios de instituciones en el rango de fechas visible + $aniversarios = Instituciones::whereBetween('aniversario', [$start, $end]) + ->select('id', 'nombre', 'aniversario') + ->get(); + + // Combinar los datos en un solo array para el calendario + $eventos = $cumpleanios->map(function ($contacto) { + return [ + 'id' => $contacto->id, + 'title' => $contacto->nombre . ' ' . $contacto->ap_paterno. ' ' . $contacto->ap_materno, + 'start' => now()->year . '-' . str_pad($contacto->mes_cump, 2, '0', STR_PAD_LEFT) . '-' . str_pad($contacto->dia_cump, 2, '0', STR_PAD_LEFT), + 'className' => 'success', + 'description' => 'Cumpleaños de ' . $contacto->nombre, + ]; + })->merge($aniversarios->map(function ($institucion) { + return [ + 'id' => $institucion->id, + 'title' => 'Aniversario de ' . $institucion->nombre, + 'start' => $institucion->aniversario, + 'className' => 'danger', + 'description' => 'Aniversario de ' . $institucion->nombre, + ]; + })); + + return response()->json($eventos); + } } + + \ No newline at end of file -- GitLab From e44dee93afd24a6b70649af0359e339a9e3d2697 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 14:07:10 -0600 Subject: [PATCH 2/6] Vista principal del sistema --- resources/views/dashboard.blade.php | 597 +++++++++------------------- 1 file changed, 177 insertions(+), 420 deletions(-) diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 3c91974..0be8d57 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -1,449 +1,206 @@ - -
- -
- + + +
+
+
+
+
+
Calendario de aniversarios
+
+
+
+
Contactos
+
+
+
+
Instituciones y empresas
+
+
+
+ +
+
+
+ -- GitLab From 90e5229ac4324d8222c8d79f3ca3b03f21835714 Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 14:07:23 -0600 Subject: [PATCH 3/6] Ruta que trae los datos del backend --- routes/web.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/web.php b/routes/web.php index 1cab2b3..5e2121c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -124,6 +124,7 @@ Route::get('/contactos/{id}/editar', [ContactoController::class, 'edit'])->name('edit')->middleware(CheckRoles::class . ':admingen,admin,capturista' ); Route::put('/contactos/{id}/editar', [ContactoController::class, 'update'])->name('update')->middleware(CheckRoles::class . ':admingen,admin,capturista' ); Route::delete('/contactos/{id}', [ContactoController::class, 'destroy'])->name('destroy')->middleware(CheckRoles::class . ':admingen,admin'); + Route::get('/administracion/datos', [ContactoController::class, 'obtenerEventos'])->name('datos')->middleware(CheckRoles::class . ':admingen,admin,capturista,lector');; }); Route::middleware('auth:sanctum', -- GitLab From 3177052ba8f68efe1963a7cc89355b0ef3fb5e8b Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 15:06:46 -0600 Subject: [PATCH 4/6] Implementacion de profesiones --- app/Http/Controllers/ContactoController.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ContactoController.php b/app/Http/Controllers/ContactoController.php index d86522a..bbb2670 100644 --- a/app/Http/Controllers/ContactoController.php +++ b/app/Http/Controllers/ContactoController.php @@ -570,6 +570,8 @@ public function upload(Request $request) 'csv_file' => 'required|mimes:csv,txt', ]); + $profesiones = Profesion::select('id', 'nombre')->get(); + $path = $request->file('csv_file')->getRealPath(); $content = file_get_contents($path); $content = str_replace("\xEF\xBB\xBF", '', $content); @@ -583,7 +585,9 @@ public function upload(Request $request) } $row = array_combine($header, $row); - $contacto = Contacto::create([ + $existProfesion = $profesiones->firstWhere('nombre', $row['profesion']); + + $datosContacto = [ 'nombre' => $row['nombre'], 'ap_paterno' => $row['ap_paterno'], 'ap_materno' => $row['ap_materno'], @@ -604,7 +608,13 @@ public function upload(Request $request) 'pais_par' => $row['pais_par'], 'finado' => $row['finado'], 'foto_perfil' => 'assets/images/profile-icon.webp' - ]); + ]; + + if(isset($existProfesion)){ + $datosContacto['profesion_id'] = $existProfesion->id; + } + + $contacto = Contacto::create($datosContacto); // Procesar teléfonos $prefijos = explode(';', $row['prefijo']); -- GitLab From 54384fd2e4bc16136cb22dc121773041e8ba951e Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 15:07:01 -0600 Subject: [PATCH 5/6] Se agrego el campo de profesion al archivo --- public/assets/formato/data.csv | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/assets/formato/data.csv b/public/assets/formato/data.csv index bb9b28b..febabb1 100644 --- a/public/assets/formato/data.csv +++ b/public/assets/formato/data.csv @@ -1,4 +1,4 @@ -nombre,ap_paterno,ap_materno,cargo_desc,mes_cump,dia_cump,domicilio_oficial,codigo_postal,localidad_oficial,municipio_oficial,estado,pais,domicilio_par,codigo_postal_par,localidad_par,municipio_par,estado_par,pais_par,finado,prefijo,lada,numero,tipo,estatus,ext,id_radio,observaciones,red_social,tipo_red_social,correo_electronico,tipo_correo_electronico -John,Doe,,Amigo del hijo del C. Gobernador,2,12,Conocido,98000,Zacatecas,Zacatecas,Zacatecas,México,Conocido,98000,Zacatecas,Zacatecas,Zacatecas,México,0,123;124,456;457,7890123456;1234567890,Celular;Fax,Público;Privado,123;124,123;124,Nota 1;Nota 2,http://facebook.com/johndoe;http://twitter.com/johndoe,Facebook;Twitter,johndoe@example.com;johndoe123@example.com,Oficial;Personal -Jane,Smith,,Amigo del hijo del C. Gobernador,10,10,Conocido,98612,Guadalupe,Guadalupe,Zacatecas,México,Conocido,98612,Guadalupe,Guadalupe,Zacatecas,México,1,321;322,654;655,9876543210;1122334455,Particular;Directo,Privado;Público,456;457,456;457,Otra nota 1;Otra nota 2,http://twitter.com/janesmith;http://linkedin.com/janesmith,Twitter;LinkedIn,janesmith@example.com;janesmith123@example.com,Personal;Oficial -Bob ,Johnson,,Amigo del hijo del C. Gobernador,12,2,Conocido,98640,Trancoso,Trancoso,Zacatecas,México,Conocido,98640,Trancoso,Trancoso,Zacatecas,México,0,555;556;557,123;124;125,1112223333;4445556666;7778889999,Radio;Celular;Fax,Público;Privado;Público,101;102;103,555;556;557,Observación 1;Observación 2;Observación 3,http://facebook.com/bobjohnson;http://instagram.com/bobjohnson,Facebook;Instagram,bobjohnson@example.com;bobjohnson123@example.com,Oficial;Personal +nombre,ap_paterno,ap_materno,cargo_desc,mes_cump,dia_cump,domicilio_oficial,codigo_postal,localidad_oficial,municipio_oficial,estado,pais,domicilio_par,codigo_postal_par,localidad_par,municipio_par,estado_par,pais_par,finado,prefijo,lada,numero,tipo,estatus,ext,id_radio,observaciones,red_social,tipo_red_social,correo_electronico,tipo_correo_electronico,profesion +John,Doe,,Amigo del hijo del C. Gobernador,2,12,Conocido,98000,Zacatecas,Zacatecas,Zacatecas,México,Conocido,98000,Zacatecas,Zacatecas,Zacatecas,México,0,123;124,456;457,7890123456;1234567890,Celular;Fax,Público;Privado,123;124,123;124,Nota 1;Nota 2,http://facebook.com/johndoe;http://twitter.com/johndoe,Facebook;Twitter,johndoe@example.com;johndoe123@example.com,Oficial;Personal,Agente de Ministerio Público +Jane,Smith,,Amigo del hijo del C. Gobernador,10,10,Conocido,98612,Guadalupe,Guadalupe,Zacatecas,México,Conocido,98612,Guadalupe,Guadalupe,Zacatecas,México,1,321;322,654;655,9876543210;1122334455,Particular;Directo,Privado;Público,456;457,456;457,Otra nota 1;Otra nota 2,http://twitter.com/janesmith;http://linkedin.com/janesmith,Twitter;LinkedIn,janesmith@example.com;janesmith123@example.com,Personal;Oficial,Almirante de Cuerpo General +Bob ,Johnson,,Amigo del hijo del C. Gobernador,12,2,Conocido,98640,Trancoso,Trancoso,Zacatecas,México,Conocido,98640,Trancoso,Trancoso,Zacatecas,México,0,555;556;557,123;124;125,1112223333;4445556666;7778889999,Radio;Celular;Fax,Público;Privado;Público,101;102;103,555;556;557,Observación 1;Observación 2;Observación 3,http://facebook.com/bobjohnson;http://instagram.com/bobjohnson,Facebook;Instagram,bobjohnson@example.com;bobjohnson123@example.com,Oficial;Personal,Arqueólogo -- GitLab From 2583b479fd45eddc564f3d1774a01245c2965dca Mon Sep 17 00:00:00 2001 From: Alfonso Rafael Solis Rangel Date: Mon, 14 Oct 2024 15:10:23 -0600 Subject: [PATCH 6/6] Comentario --- app/Http/Controllers/ContactoController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Http/Controllers/ContactoController.php b/app/Http/Controllers/ContactoController.php index bbb2670..56cf2a9 100644 --- a/app/Http/Controllers/ContactoController.php +++ b/app/Http/Controllers/ContactoController.php @@ -585,6 +585,8 @@ public function upload(Request $request) } $row = array_combine($header, $row); + //TODO: Implementar lo mismo para los demas catalogos + $existProfesion = $profesiones->firstWhere('nombre', $row['profesion']); $datosContacto = [ -- GitLab