@@ -15,7 +15,7 @@ class Auth extends \Myth\Auth\Config\Auth | |||
* | |||
* @var string | |||
*/ | |||
public $defaultUserGroup; | |||
public $defaultUserGroup = 'Prestadores'; | |||
/** | |||
* -------------------------------------------------------------------- | |||
@@ -26,6 +26,7 @@ class Filters extends BaseConfig | |||
'invalidchars' => InvalidChars::class, | |||
'secureheaders' => SecureHeaders::class, | |||
'login' => \Myth\Auth\Filters\LoginFilter::class, | |||
'role' => \Myth\Auth\Filters\RoleFilter::class, | |||
'inicio' => InicioFilter::class, | |||
'formulario_inicial' => FormularioInicialFilter::class, | |||
]; | |||
@@ -2,6 +2,8 @@ | |||
namespace Config; | |||
use CodeIgniter\Commands\Utilities\Routes; | |||
// Create a new instance of our RouteCollection class. | |||
$routes = Services::routes(); | |||
@@ -32,19 +34,49 @@ $routes->set404Override(); | |||
* Route Definitions | |||
* -------------------------------------------------------------------- | |||
*/ | |||
// We get a performance increase by specifying the default | |||
// route since we don't have to scan directories. | |||
$routes->get('/', 'Prestador::index'); | |||
$routes->get('/', 'Prestador::index', ['as' => 'home']); | |||
$routes->get('horas/', 'Prestador::horas'); | |||
$routes->match(['get', 'post'], 'registro/', 'Prestador::formulario'); | |||
$routes->get('success', 'Prestador::success'); | |||
// ENCUESTAS | |||
$routes->get('encuesta/answered', 'Encuesta::userAnswered'); | |||
$routes->get('encuesta/(:segment)', 'Encuesta::encuesta/$1', ['as' => 'encuesta']); | |||
$routes->post('encuesta/submit/(:segment)', 'Encuesta::submit/$1', ['as' => 'encuesta_submit']); | |||
// utilizar m�todo attemptRegister personalizdo (no requiere de username) | |||
$routes->post('register/', 'Auth::attemptRegister'); | |||
// $routes->post('login/', 'Auth::attemptLogin'); | |||
$routes->group('admin', static function ($routes) { | |||
$routes->group('admin', ['filter' => 'role:Admin'], static function ($routes) { | |||
$routes->get('/', 'Admin::home', ['as' => 'admin_home']); | |||
// SOLICITUDES | |||
$routes->get('solicitudes/', 'Admin::solicitudes', ['as' => 'admin_solicitudes']); | |||
$routes->get('solicitud/aprobar/(:segment)', 'Admin::aprobarSolicitud/$1', ['as' => 'admin_solicitud_aprobar']); | |||
$routes->get('solicitud/rechazar/(:segment)', 'Admin::rechazarSolicitud/$1', ['as' => 'admin_solicitud_rechazar']); | |||
$routes->get('solicitud/(:segment)', 'Admin::revisarSolicitud/$1', ['as' => 'admin_solicitud_revisar']); | |||
// ENCUESTAS | |||
$routes->get('encuestas/', 'Admin::encuestas', ['as' => 'admin_encuestas']); | |||
$routes->match(['get', 'post'], 'encuesta/nueva', 'Admin::nuevaEncuesta', ['as' => 'admin_encuesta_nueva']); | |||
$routes->get('encuesta/(:segment)', 'Admin::encuesta/$1', ['as' => 'admin_encuesta']); | |||
$routes->match(['get', 'post'], 'encuesta/editar/(:segment)', 'Admin::editarEncuesta/$1', ['as' => 'admin_encuesta_editar']); | |||
$routes->get('encuesta/eliminar/(:segment)', 'Admin::eliminarEncuesta/$1', ['as' => 'admin_encuesta_eliminar']); | |||
// PREGUNTAS | |||
$routes->match(['get', 'post'], 'encuesta/(:segment)/pregunta/', 'Admin::nuevaPregunta/$1', ['as' => 'admin_pregunta_nueva']); | |||
$routes->match(['get', 'post'], 'pregunta/editar/(:segment)', 'Admin::editarPregunta/$1', ['as' => 'admin_pregunta_editar']); | |||
$routes->post('pregunta_post', 'Admin::preguntaPost', ['as' => 'pregunta_post']); | |||
$routes->get('pregunta/eliminar/(:segment)', 'Admin::eliminarPregunta/$1', ['as' => 'admin_pregunta_eliminar']); | |||
// GRUPOS | |||
$routes->get('create_group/', 'Admin::createGroup'); | |||
}); | |||
@@ -2,11 +2,290 @@ | |||
namespace App\Controllers; | |||
use App\Entities\PrestadorSolicitudModel; | |||
use App\Models\EncuestaModel; | |||
use App\Models\PreguntaModel; | |||
use App\Models\PrestadorModel; | |||
use App\Models\PrestadorSolicitudModel as ModelsPrestadorSolicitudModel; | |||
use App\Models\UserModel; | |||
class Admin extends BaseController | |||
{ | |||
public function home() | |||
{ | |||
$data['title'] = 'Inicio'; | |||
$data = [ | |||
'title' => 'Inicio', | |||
'solicitudes' => model(PrestadorSolicitudModel::class)->countSolicitudes(), | |||
'prestadoresActivos' => model(PrestadorModel::class)->countPrestadoresActivos(), | |||
]; | |||
return view('Admin/index', $data); | |||
} | |||
// SOLICITUDES | |||
public function solicitudes() | |||
{ | |||
$data = [ | |||
'title' => 'Solicitudes', | |||
'solicitudes' => model(PrestadorSolicitudModel::class)->getPrestadorSolicitud(), | |||
]; | |||
return view('Admin/solicitudes', $data); | |||
} | |||
public function revisarSolicitud($id) | |||
{ | |||
$model = model(ModelsPrestadorSolicitudModel::class); | |||
if (!$datos = $model->find($id)) { | |||
return redirect()->route('admin_solicitudes')->with('msg', array( | |||
'type' => 'danger', | |||
'body' => 'Solicitud no encontrada' | |||
)); | |||
} | |||
$data = [ | |||
'id' => $id, | |||
'email' => user()->email, | |||
'escuelas' => model(EscuelaModel::class)->getEscuelas(), | |||
'departamentos' => model(DepartamentoModel::class)->getDepartamentos(), | |||
'datos' => $datos, | |||
'revisar' => true, | |||
]; | |||
return view('Prestador/formulario_inicial', $data); | |||
} | |||
public function aprobarSolicitud($id) | |||
{ | |||
$solicitudModel = model(ModelsPrestadorSolicitudModel::class); | |||
// Validar que la solicitud existe | |||
if (!$solicitud = $solicitudModel->find($id)) { | |||
return redirect()->route('admin_solicitudes')->with('msg', array( | |||
'type' => 'danger', | |||
'body' => 'Solicitud no encontrada' | |||
)); | |||
} | |||
// Verificar que status de la solicitud == 0 | |||
if ($solicitud['status'] != 0) { | |||
return redirect()->route('admin_solicitudes')->with('msg', array( | |||
'type' => 'danger', | |||
'body' => 'El status de esta solicitud no permite que sea aprobada' | |||
)); | |||
} | |||
// Encontrar usuario que mandó la solicitud | |||
if (!$user = model(UserModel::class)->findUserWithSolicitud($id)) { | |||
return redirect()->route('admin_solicitudes')->with('msg', array( | |||
'type' => 'danger', | |||
'body' => 'Ningún usuario tiene esa solicitud registrada.' | |||
)); | |||
} | |||
// Crear registro en la tabla prestador | |||
$prestadorModel = model(PrestadorModel::class); | |||
// Asignar id de la tabla prestador al usuario aprobado | |||
// Cambiar status de la solicitud | |||
return redirect()->route('admin_solicitudes')->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Solicitud aprobada. Se activo la cuenta del prestador.' | |||
)); | |||
} | |||
public function rechazarSolicitud($id) | |||
{ | |||
echo 'rechazandp solicitud ' . $id; | |||
} | |||
// ENCUESTAS | |||
public function encuestas() | |||
{ | |||
$data = [ | |||
'title' => 'Encuestas', | |||
'encuestas' => model(EncuestaModel::class)->getEncuestas(), | |||
]; | |||
return view('Admin/encuestas.php', $data); | |||
} | |||
public function encuesta($id) | |||
{ | |||
$data = [ | |||
'id' => $id, | |||
'encuesta' => model(EncuestaModel::class)->getEncuestas($id, true), | |||
'preguntas' => model(PreguntaModel::class)->getPreguntas($id), | |||
]; | |||
return view('Admin/encuesta', $data); | |||
} | |||
public function nuevaEncuesta() | |||
{ | |||
// Guardar encuesta | |||
if ($this->request->getMethod() === 'post') { | |||
$encuesta = model(EncuestaModel::class); | |||
$data = $this->request->getPost(); | |||
// agregar id del usuario actual | |||
$data['user_id'] = user_id(); | |||
// Validar datos | |||
if (!$encuesta->save($data)) { | |||
return redirect()->back()->withInput()->with('errors', $encuesta->errors()); | |||
} | |||
return redirect()->route('admin_encuestas')->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Encuesta creada correctamente.' | |||
)); | |||
} | |||
$data = [ | |||
'title' => 'Nueva encuesta', | |||
]; | |||
return view('Admin/formularioEncuesta', $data); | |||
} | |||
public function editarEncuesta($id) | |||
{ | |||
$encuesta = model(EncuestaModel::class); | |||
if ($this->request->getMethod() === 'post') { | |||
$data = $this->request->getPost(); | |||
if (!$encuesta->update($id, $data)) { | |||
return redirect()->back()->withInput()->with('errors', $encuesta->errors()); | |||
} | |||
return redirect()->route('admin_encuestas')->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Encuesta editada correctamente', | |||
)); | |||
} | |||
$data = [ | |||
'id' => $id, | |||
'title' => 'Modificar encuesta', | |||
'datos' => $encuesta->getEncuestas($id), | |||
]; | |||
return view('Admin/formularioEncuesta', $data); | |||
} | |||
public function eliminarEncuesta($id) | |||
{ | |||
if (!model(EncuestaModel::class)->delete($id)) { | |||
return redirect()->route('admin_encuestas')->with('msg', array( | |||
'type' => 'error', | |||
'body' => 'Error al eliminar la encuesta.' | |||
)); | |||
} | |||
return redirect()->route('admin_encuestas')->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Encuesta eliminada correctamente.' | |||
)); | |||
} | |||
// PREGUNTAS | |||
public function nuevaPregunta($id) | |||
{ | |||
if ($this->request->getMethod() === 'post') { | |||
$pregunta = model(PreguntaModel::class); | |||
$data = $this->request->getPost(); | |||
// Relacionar encuesta($id) con pregunta(survey_id) | |||
$data['survey_id'] = $id; | |||
$data['order_by'] = 1; | |||
// Validar y guardar datos | |||
if (!$pregunta->save($data)) { | |||
return redirect()->back()->withInput()->with('errors', $pregunta->errors()); | |||
} | |||
$url = 'admin/encuesta/' . $id; | |||
return redirect()->to($url)->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Pregunta registrada correctamente', | |||
)); | |||
} | |||
$data = [ | |||
'title' => 'Nueva pregunta', | |||
'id' => $id, | |||
]; | |||
return view('Admin/formularioPregunta', $data); | |||
} | |||
public function editarPregunta($id) | |||
{ | |||
$pregunta = model(PreguntaModel::class); | |||
if ($this->request->getMethod() === 'post') { | |||
$data = $this->request->getPost(); | |||
if (!$pregunta->update($id, $data)) { | |||
return redirect()->back()->withInput()->with('errors', $pregunta->errors()); | |||
} | |||
$encuestaId = $pregunta->find($id)['survey_id']; | |||
$url = 'admin/encuesta/' . $encuestaId; | |||
return redirect()->to($url)->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Pregunta registrada correctamente', | |||
)); | |||
} | |||
$data = [ | |||
'preguntaId' => $id, | |||
'title' => 'Editar pregunta', | |||
'datos' => $pregunta->find($id), | |||
]; | |||
return view('Admin/formularioPregunta', $data); | |||
} | |||
public function eliminarPregunta(int $id) | |||
{ | |||
$model = model('PreguntaModel'); | |||
if (!$pregunta = $model->find($id)) { | |||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); | |||
} | |||
$encuestaId = $pregunta['survey_id']; | |||
$model->delete($id); | |||
$url = 'admin/encuesta/' . $encuestaId; | |||
return redirect()->to($url)->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Pregunta eliminada correctamente', | |||
)); | |||
} | |||
public function preguntaPost() | |||
{ | |||
$data = $this->request->getPost(); | |||
$data['survey_id'] = 1; | |||
$data['order_by'] = 1; | |||
var_dump($data); | |||
} | |||
// GRUPOS | |||
public function createGroup() | |||
{ | |||
// $authorize = service('authorization'); | |||
// $id = $authorize->createGroup('Prestador', 'Prestadores de Servicio Social o Prácticas Profesionales'); | |||
// echo $id; | |||
} | |||
} |
@@ -68,4 +68,45 @@ class Auth extends MythAuthController | |||
// Success! | |||
return redirect()->route('login')->with('message', lang('Auth.registerSuccess')); | |||
} | |||
public function attemptLogin() | |||
{ | |||
$rules = [ | |||
'login' => 'required', | |||
'password' => 'required', | |||
]; | |||
if ($this->config->validFields === ['email']) { | |||
$rules['login'] .= '|valid_email'; | |||
} | |||
if (!$this->validate($rules)) { | |||
return redirect()->back()->withInput()->with('errors', $this->validator->getErrors()); | |||
} | |||
$login = $this->request->getPost('login'); | |||
$password = $this->request->getPost('password'); | |||
$remember = (bool) $this->request->getPost('remember'); | |||
// Determine credential type | |||
$type = filter_var($login, FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; | |||
// Try to log them in... | |||
if (!$this->auth->attempt([$type => $login, 'password' => $password], $remember)) { | |||
return redirect()->back()->withInput()->with('error', $this->auth->error() ?? lang('Auth.badAttempt')); | |||
} | |||
// Is the user being forced to reset their password? | |||
if ($this->auth->user()->force_pass_reset === true) { | |||
return redirect()->to(route_to('reset-password') . '?token=' . $this->auth->user()->reset_hash)->withCookies(); | |||
} | |||
$redirectURL = session('redirect_url') ?? site_url('/'); | |||
unset($_SESSION['redirect_url']); | |||
helper('auth'); | |||
if (user()->in_groups('Admin')) | |||
$redirectURL = site_url('/admin'); | |||
return redirect()->to($redirectURL)->withCookies()->with('message', lang('Auth.loginSuccess')); | |||
} | |||
} |
@@ -0,0 +1,92 @@ | |||
<?php | |||
namespace App\Controllers; | |||
use App\Models\EncuestaModel; | |||
use App\Models\PreguntaModel; | |||
use App\Models\RespuestaModel; | |||
use App\Models\SurveyUserModel; | |||
use App\Models\UserModel; | |||
use phpDocumentor\Reflection\DocBlock\Tags\TagWithType; | |||
class Encuesta extends BaseController | |||
{ | |||
public function encuesta($id) | |||
{ | |||
if (!$encuesta = model(EncuestaModel::class)->find($id)) { | |||
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound(); | |||
} | |||
$data = [ | |||
'id' => $encuesta['id'], | |||
'title' => $encuesta['title'], | |||
'preguntas' => model(PreguntaModel::class)->getPreguntas($id), | |||
]; | |||
return view('Encuesta/template', $data); | |||
} | |||
public function submit($id) | |||
{ | |||
$respuestaModel = model(RespuestaModel::class); | |||
$userId = user_id(); | |||
$data = $this->request->getPost(); | |||
$respuestas = []; | |||
foreach ($data as $questionId => $answer) { | |||
if (is_array($answer)) { | |||
foreach ($answer as $a) { | |||
$respuesta = [ | |||
'survey_id' => $id, | |||
'user_id' => $userId, | |||
'answer' => $a, | |||
'question_id' => $questionId, | |||
]; | |||
array_push($respuestas, $respuesta); | |||
} | |||
} else { | |||
$respuesta = [ | |||
'survey_id' => $id, | |||
'user_id' => $userId, | |||
'answer' => $answer, | |||
'question_id' => $questionId, | |||
]; | |||
array_push($respuestas, $respuesta); | |||
} | |||
// $answer = implode(chr(13), $answer); | |||
}; | |||
if (!$respuestaModel->insertBatch($respuestas)) { | |||
return redirect()->back() | |||
->with('msg', array( | |||
'type' => 'danger', | |||
'body' => 'No se pudo guardar la encuesta. Inténtalo nuevamente.' | |||
)); | |||
} | |||
// Registrar que usuario respondió encuesta | |||
$surveyUserModel = model(SurveyUserModel::class); | |||
$surveyUserModel->save([ | |||
'survey_id' => $id, | |||
'user_id' => $userId, | |||
]); | |||
return redirect()->route('home')->with('msg', array( | |||
'type' => 'success', | |||
'body' => 'Encuesta guardada correctamente' | |||
)); | |||
} | |||
public function userAnswered() | |||
{ | |||
$surveyUserModel = model(SurveyUserModel::class); | |||
$encuestaId = 23; | |||
$userId = user_id(); | |||
echo $surveyUserModel->alreadyAnswered($encuestaId, $userId); | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace App\Controllers; | |||
use App\Models\DepartamentoModel; | |||
use App\Models\EncuestaModel; | |||
use App\Models\EscuelaModel; | |||
use App\Models\HorasModel; | |||
use App\Models\PrestadorModel; | |||
@@ -24,11 +25,18 @@ class Prestador extends BaseController | |||
return $carry + $item['segundos']; | |||
}, 0); | |||
// Consultar encuestas disponibles | |||
$encuestaModel = model(EncuestaModel::class); | |||
$horasARealizar = model(PrestadorModel::class)->find(user()->idprestador)['horas_servicio']; | |||
$porcentajeRealizado = $segundosTotal / ($horasARealizar * 1000); | |||
$encuestas = $encuestaModel->getPrestadorEncuestas($porcentajeRealizado); | |||
$data = [ | |||
'segundosMensuales' => $segundosMensuales, | |||
'horasTotales' => $segundosTotal / 3600, | |||
'segundosDiarios' => $segundosDiarios, | |||
'encuestas' => $encuestas, | |||
]; | |||
return view('Prestador/index', $data); | |||
@@ -75,8 +83,9 @@ class Prestador extends BaseController | |||
'email' => user()->email, | |||
'escuelas' => model(EscuelaModel::class)->getEscuelas(), | |||
'departamentos' => model(DepartamentoModel::class)->getDepartamentos(), | |||
'datos' => $prestadorModel->getPrestadorSolicitud(user()->rh_prestador_solicitud_id), | |||
'datos' => user()->rh_prestador_solicitud_id ? $prestadorModel->find(user()->rh_prestador_solicitud_id) : null, | |||
]; | |||
return view('Prestador/formulario_inicial', $data); | |||
} | |||
} |
@@ -0,0 +1,63 @@ | |||
<?php | |||
namespace App\Models; | |||
use CodeIgniter\Model; | |||
class EncuestaModel extends Model | |||
{ | |||
protected $table = 'survey_set'; | |||
protected $primaryKey = 'id'; | |||
protected $useTimestamps = true; | |||
protected $allowedFields = ['title', 'description', 'user_id', 'perfil', 'fecha', 'status']; | |||
protected $validationRules = [ | |||
'title' => 'required', | |||
'user_id' => 'required', | |||
'perfil' => 'required', | |||
'fecha' => 'required', | |||
'status' => 'required', | |||
]; | |||
public function getEncuestas($id = null, $verbose = false) | |||
{ | |||
if (!$id) { | |||
return $this->findAll(); | |||
} | |||
$encuesta = $this->where('id', $id)->first(); | |||
if ($verbose && $encuesta) { | |||
$encuesta['perfil_nombre'] = $encuesta['perfil'] == 1 ? 'Personal de CEJ' : 'Prestador'; | |||
$encuesta['status_nombre'] = $encuesta['status'] == 0 ? 'No publicada' : 'Publicada'; | |||
switch ($encuesta['fecha']) { | |||
case 1: | |||
$encuesta['fecha_nombre'] = 'Inicio de servicio'; | |||
break; | |||
case 2: | |||
$encuesta['fecha_nombre'] = '50% de horas o más'; | |||
break; | |||
case 3: | |||
$encuesta['fecha_nombre'] = 'Al terminar el servicio'; | |||
break; | |||
} | |||
} | |||
return $encuesta; | |||
} | |||
public function getPrestadorEncuestas($porcentajeCompletado) | |||
{ | |||
$fecha = 1 + $porcentajeCompletado * 2; | |||
return $this | |||
->select(['id', 'title']) | |||
->where('perfil', 2) | |||
->where('fecha <=', $fecha) | |||
->findAll(); | |||
} | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace App\Models; | |||
use CodeIgniter\Model; | |||
class PreguntaModel extends Model | |||
{ | |||
protected $table = 'questions'; | |||
protected $primaryKey = 'id'; | |||
protected $useTimestamps = true; | |||
protected $allowedFields = ['question', 'frm_option', 'type', 'order_by', 'survey_id']; | |||
protected $validationRules = [ | |||
'question' => 'required', | |||
'survey_id' => 'required', | |||
'type' => 'required', | |||
]; | |||
public function getPreguntas($encuestaId) | |||
{ | |||
return $this | |||
->where('survey_id', $encuestaId) | |||
->findAll(); | |||
} | |||
} |
@@ -10,9 +10,25 @@ class PrestadorModel extends Model | |||
protected $primaryKey = 'idprestador'; | |||
protected $useTimestamps = false; | |||
protected $allowedFields = [ | |||
'nombre', 'apaterno', 'amaterno', 'fechanac', | |||
'direccion', 'colonia', 'municipio', 'cp', | |||
'telefono', 'celular', 'email', | |||
'idescuela', 'carrera', 'grado', 'turno', | |||
'tipo', 'fechainicio', 'iddepartamento_actual', 'horas_servicio', | |||
'codigo_estudiante', 'horario', | |||
]; | |||
function getPrestador($id = null) | |||
{ | |||
return $this->where('idprestador', $id)->first(); | |||
} | |||
function countPrestadoresActivos() | |||
{ | |||
return $this | |||
->where('status', 0) | |||
->countAllResults(); | |||
} | |||
} |
@@ -54,14 +54,19 @@ class PrestadorSolicitudModel extends Model | |||
]; | |||
// protected $validationMessages = [ | |||
// 'email' => [ | |||
// 'is_unique' => 'Sorry. That email has already been taken. Please choose another.', | |||
// ], | |||
// ]; | |||
function getPrestadorSolicitud($id = null) | |||
{ | |||
if (!$id) { | |||
return $this->where('status', 0)->findAll(); | |||
} | |||
return $this->where('id', $id)->first(); | |||
} | |||
function countSolicitudes() | |||
{ | |||
return $this | |||
->where('status', 0) | |||
->countAllResults(); | |||
} | |||
} |
@@ -0,0 +1,21 @@ | |||
<?php | |||
namespace App\Models; | |||
use CodeIgniter\Model; | |||
class PreguntaModel extends Model | |||
{ | |||
protected $table = 'answers'; | |||
protected $primaryKey = 'id'; | |||
protected $useTimestamps = true; | |||
protected $allowedFields = ['survey_id', 'user_id', 'answer', 'question_id']; | |||
protected $validationRules = [ | |||
'survey_id' => 'required', | |||
'user_id' => 'required', | |||
'answer' => 'required', | |||
'question_id' => 'required', | |||
]; | |||
} |
@@ -0,0 +1,27 @@ | |||
<?php | |||
namespace App\Models; | |||
use CodeIgniter\Model; | |||
class SurveyUserModel extends Model | |||
{ | |||
protected $table = 'survey_user'; | |||
protected $useTimestamps = true; | |||
protected $allowedFields = ['survey_id', 'user_id']; | |||
protected $validationRules = [ | |||
'survey_id' => 'required', | |||
'user_id' => 'required', | |||
]; | |||
public function alreadyAnswered($surveyId, $userId) | |||
{ | |||
return $this->where([ | |||
'survey_id' => $surveyId, | |||
'user_id' => $userId, | |||
])->countAllResults(); | |||
} | |||
} |
@@ -120,4 +120,13 @@ class UserModel extends Model | |||
'password' => bin2hex(random_bytes(16)), | |||
]); | |||
} | |||
public function findUserWithSolicitud($solicitudId) | |||
{ | |||
return $this | |||
// ->select('id') | |||
->where('rh_prestador_solicitud_id', $solicitudId) | |||
->first(); | |||
} | |||
} |
@@ -0,0 +1,95 @@ | |||
<?= $this->extend('templates/baseAdmin') ?> | |||
<?= $this->section('content') ?> | |||
<div class="card"> | |||
<div class="card-body"> | |||
<h5 class="card-title"><?= $encuesta['title'] ?></h5> | |||
<br> | |||
<p><?= $encuesta['description'] ?></p> | |||
<p>Perfil: <strong><?= $encuesta['perfil_nombre'] ?></strong></p> | |||
<p>Fecha: <strong><?= $encuesta['fecha_nombre'] ?></strong></p> | |||
<p>Status: <strong><?= $encuesta['status_nombre'] ?></strong></p> | |||
<a href="<?= route_to('admin_encuesta_editar', $id) ?>" class="card-link">Editar encuesta</a> | |||
</div> | |||
</div> | |||
<div class="d-flex justify-content-between mb-3"> | |||
<h2>Preguntas</h2> | |||
<a href="<?= route_to('admin_pregunta_nueva', $id) ?>" class="btn btn-outline-dark align-items-start mr-3"><i class="right fas fa-plus-circle"></i> Nueva pregunta</a> | |||
</div> | |||
<table class="table"> | |||
<thead> | |||
<th>Pregunta</th> | |||
<th>Tipo</th> | |||
<th>Opciones</th> | |||
<th>Acciones</th> | |||
</thead> | |||
<tbody> | |||
<?php foreach ($preguntas as $pregunta) : ?> | |||
<tr> | |||
<td><?= $pregunta['question'] ?></td> | |||
<td> | |||
<?php if ($pregunta['type'] == '1') echo 'Texto'; | |||
else if ($pregunta['type'] == '2') echo 'Selección única'; | |||
else if ($pregunta['type'] == '3') echo 'Selección múltiple' ?> | |||
</td> | |||
<td><?= $pregunta['frm_option'] ?></td> | |||
<td> | |||
<div class="button-group mr-2" role="group"> | |||
<a href="<?= route_to('admin_pregunta_editar', $pregunta['id']) ?>" class="btn btn-info "> | |||
<i class="nav-icon fas fa-edit"></i> | |||
</a> | |||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#eliminarModal" data-id="<?= $pregunta['id'] ?>" data-question="<?= $pregunta['question'] ?>" data-link="<?= route_to('admin_pregunta_eliminar', $pregunta['id'], $id) ?>"> | |||
<i class="nav-icon fas fa-trash"></i> | |||
</button> | |||
</div> | |||
</td> | |||
</tr> | |||
<?php endforeach ?> | |||
</tbody> | |||
</table> | |||
<!-- Modal: eliminar encuesta --> | |||
<div class="modal fade" id="eliminarModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | |||
<div class="modal-dialog" role="document"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h5 class="modal-title" id="exampleModalLabel">Eliminar Pregunta</h5> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
</div> | |||
<div class="modal-footer"> | |||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button> | |||
<a href="#" id="eliminar-link" class="btn btn-danger">Eliminar</a> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<script src="plugins/jquery/jquery.min.js"></script> | |||
<script> | |||
$(document).ready(function() { | |||
$('#eliminarModal').on('show.bs.modal', (event) => { | |||
let button = $(event.relatedTarget) | |||
let preguntaId = button.data('id') | |||
let preguntaTitle = button.data('question') | |||
let preguntaLink = button.data('link') | |||
let modal = $(this) | |||
// modal.find('.modal-title').text('New message to ' + recipient) | |||
modal.find('.modal-body').text('Eliminar: ' + preguntaTitle) | |||
modal.find('#eliminar-link').attr('href', preguntaLink) | |||
}) | |||
}) | |||
</script> | |||
<?= $this->endSection() ?> |
@@ -0,0 +1,74 @@ | |||
<?= $this->extend('templates/baseAdmin') ?> | |||
<?= $this->section('content') ?> | |||
<table class="table table-striped" style="table-layout: fixed; word-wrap: break-word;"> | |||
<thead class=""> | |||
<th>Título</th> | |||
<th colspan="3">Descripción</th> | |||
<th>Opciones</th> | |||
</thead> | |||
<tbody> | |||
<?php foreach ($encuestas as $encuesta) : ?> | |||
<tr> | |||
<td><?= esc($encuesta['title']) ?></td> | |||
<td colspan="3"><?= esc($encuesta['description']) ?></td> | |||
<td> | |||
<div class="button-group mr-2" role="group"> | |||
<a href="<?= route_to('admin_encuesta_editar', $encuesta['id']) ?>" class="btn btn-info "> | |||
<i class="nav-icon fas fa-edit"></i> | |||
</a> | |||
<a href="<?= route_to('admin_encuesta', $encuesta['id']) ?>" class="btn btn-success "> | |||
<i class="nav-icon fas fa-eye"></i> | |||
</a> | |||
<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#eliminarModal" data-id="<?= $encuesta['id'] ?>" data-title="<?= $encuesta['title'] ?>" data-link="<?= route_to('admin_encuesta_eliminar', $encuesta['id']) ?>"> | |||
<i class="nav-icon fas fa-trash"></i> | |||
</button> | |||
</div> | |||
</td> | |||
</tr> | |||
<?php endforeach ?> | |||
</tbody> | |||
</table> | |||
<!-- Modal: eliminar encuesta --> | |||
<div class="modal fade" id="eliminarModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"> | |||
<div class="modal-dialog" role="document"> | |||
<div class="modal-content"> | |||
<div class="modal-header"> | |||
<h5 class="modal-title" id="exampleModalLabel">Eliminar Encuesta</h5> | |||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<div class="modal-body"> | |||
</div> | |||
<div class="modal-footer"> | |||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancelar</button> | |||
<a href="#" id="eliminar-link" class="btn btn-danger">Eliminar</a> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<script src="plugins/jquery/jquery.min.js"></script> | |||
<script> | |||
$(document).ready(function() { | |||
$('#eliminarModal').on('show.bs.modal', (event) => { | |||
let button = $(event.relatedTarget) | |||
let encuestaId = button.data('id') | |||
let encuestaTitle = button.data('title') | |||
let encuestaLink = button.data('link') | |||
let modal = $(this) | |||
// modal.find('.modal-title').text('New message to ' + recipient) | |||
modal.find('.modal-body').text('Eliminar: ' + encuestaTitle) | |||
modal.find('#eliminar-link').attr('href', encuestaLink) | |||
}) | |||
}) | |||
</script> | |||
<?= $this->endSection() ?> |
@@ -0,0 +1,45 @@ | |||
<?= $this->extend('templates/baseAdmin') ?> | |||
<?= $this->section('content') ?> | |||
<form action="<?= isset($datos) ? route_to('admin_encuesta_editar', $id) : route_to('admin_encuesta_nueva') ?>" method="POST"> | |||
<?= csrf_field() ?> | |||
<div class="form-group"> | |||
<label for="title">Título</label> | |||
<input name="title" id="title" type="text" class="form-control" value="<?= isset($datos) ? $datos['title'] : '' ?>" required> | |||
</div> | |||
<div class="form-group"> | |||
<label for="perfil">Perfil objetivo</label> | |||
<select name="perfil" id="perfil" class="form-control" required> | |||
<option value="1" <?= (isset($datos) && $datos['perfil'] == 1) ? 'selected="selected"' : '' ?>>Personal de CEJ</option> | |||
<option value="2" <?= (isset($datos) && $datos['perfil'] == 2) ? 'selected="selected"' : '' ?>>Prestador de servicio social o prácticas</option> | |||
</select> | |||
</div> | |||
<div class="form-group"> | |||
<label for="fecha">Fechas en que se solicita la encuesta</label> | |||
<select name="fecha" id="fecha" class="form-control" required> | |||
<option value="1" <?= (isset($datos) && $datos['fecha'] == 1) ? 'selected="selected"' : '' ?>>Inicio de servicio</option> | |||
<option value="2" <?= (isset($datos) && $datos['fecha'] == 2) ? 'selected="selected"' : '' ?>>50% de horas o más</option> | |||
<option value="3" <?= (isset($datos) && $datos['fecha'] == 3) ? 'selected="selected"' : '' ?>>Al terminar el servicio</option> | |||
</select> | |||
</div> | |||
<div class="form-group"> | |||
<label for="description">Descripción</label> | |||
<textarea name="description" id="description" cols="30" rows="6" class="form-control"><?= isset($datos) ? $datos['description'] : '' ?></textarea> | |||
</div> | |||
<div class="form-group"> | |||
<label for="status">Status</label> | |||
<select name="status" id="status" class="form-control" required> | |||
<option value="1" <?= (isset($datos) && $datos['status'] == 1) ? 'selected="selected"' : '' ?>>Publicada</option> | |||
<option value="0" <?= (isset($datos) && $datos['status'] == 0) ? 'selected="selected"' : '' ?>>No publicada</option> | |||
</select> | |||
</div> | |||
<a href="<?= route_to('admin_encuestas') ?>" class="btn btn-danger">Cancelar</a> | |||
<input type="submit" class="btn btn-dark" value="<?= isset($datos) ? 'Actualizar' : 'Guardar' ?>"> | |||
</form> | |||
<?= $this->endSection() ?> |
@@ -0,0 +1,44 @@ | |||
<?= $this->extend('templates/baseAdmin') ?> | |||
<?= $this->section('content') ?> | |||
<form action="<?= isset($datos) ? route_to('admin_pregunta_editar', $preguntaId) : route_to('admin_pregunta_nueva', $id) ?>" method="POST"> | |||
<?= csrf_field() ?> | |||
<div class="form-group"> | |||
<label for="question">Pregunta</label> | |||
<input type="text" name="question" id="question" class="form-control" value="<?= isset($datos) ? $datos['question'] : '' ?>" required> | |||
</div> | |||
<div class="form-group"> | |||
<label for="type">Tipo de respuesta</label> | |||
<select name="type" id="type" class="form-control" required> | |||
<option value="1" <?= (isset($datos) && $datos['type'] == 1) ? 'selected="selected"' : '' ?>>Texto</option> | |||
<option value="2" <?= (isset($datos) && $datos['type'] == 2) ? 'selected="selected"' : 'selected="selected"' ?>>Selección única</option> | |||
<option value="3" <?= (isset($datos) && $datos['type'] == 3) ? 'selected="selected"' : '' ?>>Selección múltiple</option> | |||
</select> | |||
</div> | |||
<div class="form-group" id="frm_option_div"> | |||
<label for="frm_option">Opciones <small class="form-text">(Escribir cada opción en una línea distinta)</small></label> | |||
<textarea name="frm_option" id="frm_option" cols="30" rows="5" class="form-control"><?= (isset($datos) && $datos['frm_option']) ? $datos['frm_option'] : '' ?></textarea> | |||
</div> | |||
<a href="<?= isset($datos) ? route_to('admin_encuesta', $datos['survey_id']) : route_to('admin_encuestas') ?>" class="btn btn-danger">Cancelar</a> | |||
<input type="submit" class="btn btn-dark" value="Guardar"> | |||
</form> | |||
<script src="plugins/jquery/jquery.min.js"></script> | |||
<script> | |||
$("#type").change(function() { | |||
if ($(this).val() == '1') { | |||
$('#frm_option_div').hide(); | |||
$('#frm_option').removeAttr('required'); | |||
$('#frm_option').removeAttr('data-error'); | |||
} else { | |||
$('#frm_option_div').show(); | |||
$('#frm_option').attr('required', ''); | |||
$('#frm_option').attr('data-error', 'This field is required.'); | |||
} | |||
}); | |||
</script> | |||
<?= $this->endSection() ?> |
@@ -2,6 +2,38 @@ | |||
<?= $this->section('content') ?> | |||
<h1>hey</h1> | |||
<div class="container-fluid"> | |||
<div class="row"> | |||
<div class="col-lg-4 col-6"> | |||
<div class="small-box bg-info"> | |||
<div class="inner"> | |||
<h3><?= $solicitudes ?></h3> | |||
<p>Solicitudes por revisar</p> | |||
</div> | |||
<div class="icon"> | |||
<i class="fas fa-clipboard-check"></i> | |||
</div> | |||
<a href="<?= route_to('admin_solicitudes') ?>" class="small-box-footer"> | |||
Ver lista <i class="fas fa-arrow-circle-right"></i> | |||
</a> | |||
</div> | |||
</div> | |||
<div class="col-lg-4 col-6"> | |||
<!-- small card --> | |||
<div class="small-box bg-success"> | |||
<div class="inner"> | |||
<h3><?= $prestadoresActivos ?></h3> | |||
<p>Prestadores activos</p> | |||
</div> | |||
<div class="icon"> | |||
<i class="fas fa-user-check"></i> | |||
</div> | |||
<a href="#" class="small-box-footer"> | |||
Ver lista <i class="fas fa-arrow-circle-right"></i> | |||
</a> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<?= $this->endSection() ?> |
@@ -0,0 +1,63 @@ | |||
<?= $this->extend('templates/baseAdmin') ?> | |||
<?= $this->section('content') ?> | |||
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css"> --> | |||
<script src="https://code.jquery.com/jquery-3.5.1.js"></script> | |||
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script> | |||
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script> | |||
<div class="card"> | |||
<div class="card-body"> | |||
<table id="table-solicitudes" class="table table-bordered table-striped"> | |||
<thead> | |||
<th>Nombre</th> | |||
<th>Email</th> | |||
<th>Revisar</th> | |||
</thead> | |||
<tbody> | |||
<?php foreach ($solicitudes as $solicitud) : ?> | |||
<tr> | |||
<td><?= $solicitud['nombre'] . ' ' . $solicitud['apaterno'] . ' ' . $solicitud['amaterno'] ?></td> | |||
<td><?= $solicitud['email'] ?></td> | |||
<td> | |||
<a href="<?= route_to('admin_solicitud_revisar', $solicitud['id']) ?>" class="btn btn-info "> | |||
<i class="nav-icon fas fa-user-check"></i> | |||
</a> | |||
</td> | |||
</tr> | |||
<?php endforeach ?> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | |||
<script> | |||
document.addEventListener('DOMContentLoaded', function() { | |||
let table = new DataTable('#table-solicitudes', { | |||
'searching': true, | |||
'ordering': true, | |||
'language': { | |||
"lengthMenu": "Mostrar _MENU_ registros", | |||
"info": "Página: _PAGE_ / _PAGES_", | |||
"zeroRecords": "No se encontraron registros", | |||
"paginate": { | |||
"first": "Inicio", | |||
"last": "Fin", | |||
"next": ">", | |||
"previous": "<" | |||
}, | |||
'search': 'Buscar:', | |||
}, | |||
'order': [], | |||
}); | |||
}); | |||
</script> | |||
<?= $this->endSection() ?> |
@@ -0,0 +1,54 @@ | |||
<?php | |||
use CodeIgniter\Router\Router; | |||
?> | |||
<?= $this->extend('templates/base') ?> | |||
<!-- title --> | |||
<?= $this->section('title') ?>Prestador<?= $this->endSection() ?> | |||
<!-- content --> | |||
<?= $this->section('content') ?> | |||
<h1><?= $title ?></h1> | |||
<form method="POST" action="<?= route_to('encuesta_submit', $id) ?>"> | |||
<?= csrf_field() ?> | |||
<!-- PREGUNTAS --> | |||
<?php foreach ($preguntas as $pregunta) : ?> | |||
<div class="mb-3"> | |||
<label for="<?= $pregunta['id'] ?>" class="form-label"><?= $pregunta['question'] ?></label> | |||
<!-- Pregunta texto --> | |||
<?php if ($pregunta['type'] === '1') : ?> | |||
<textarea name="<?= $pregunta['id'] ?>" id="<?= $pregunta['id'] ?>" cols="30" rows="1" class="form-control" required></textarea> | |||
<!-- Pregunta selección única --> | |||
<?php elseif ($pregunta['type'] === '2') : ?> | |||
<select class="form-control" name="<?= $pregunta['id'] ?>" id="<?= $pregunta['id'] ?>" required> | |||
<?php foreach (preg_split("/\r\n|\n|\r/", $pregunta['frm_option']) as $opcion) : ?> | |||
<option value="<?= $opcion ?>"> | |||
<?= $opcion ?> | |||
</option> | |||
<?php endforeach ?> | |||
</select> | |||
<!-- Pregunta selección múltiple --> | |||
<?php elseif ($pregunta['type'] === '3') : ?> | |||
<?php foreach (preg_split("/\r\n|\n|\r/", $pregunta['frm_option']) as $opcion) : ?> | |||
<div class="form-check"> | |||
<input class="form-check-input" type="checkbox" name="<?= $pregunta['id'] ?>[<?= $opcion ?>]" value="<?= $opcion ?>" id="<?= $opcion ?>"> | |||
<label class="form-check-label" for="<?= $opcion ?>"> | |||
<?= $opcion ?> | |||
</label> | |||
</div> | |||
<?php endforeach ?> | |||
<?php endif ?> | |||
</div> | |||
<?php endforeach ?> | |||
<a href="<?= route_to('home') ?>" class="btn btn-danger">Cancelar</a> | |||
<input type="submit" class="btn btn-dark" value="Enviar"> | |||
</form> | |||
<?= $this->endSection() ?> |
@@ -23,44 +23,44 @@ | |||
<label class="form-label" for="">Nombre*</label> | |||
<input name="nombre" type="text" class="form-control <?php if (session('errors.nombre')) : ?>is-invalid<?php endif ?>" value="<?php if (old('nombre')) echo old('nombre'); | |||
else if ($datos) echo $datos['nombre']; | |||
?>" required> | |||
?>" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Apellido Paterno*</label> | |||
<input name="apaterno" type="text" class="form-control <?php if (session('errors.apaterno')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('apaterno')) echo old('apaterno'); | |||
else if ($datos) echo $datos['apaterno']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Apellido Materno*</label> | |||
<input name="amaterno" type="text" class="form-control <?php if (session('errors.amaterno')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('amaterno')) echo old('amaterno'); | |||
else if ($datos) echo $datos['amaterno']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Fecha de Nacimiento*</label> | |||
<input name="fechanac" type="date" class="form-control <?php if (session('errors.fechanac')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('fechanac')) echo old('fechanac'); | |||
else if ($datos) echo explode(' ', $datos['fechanac'])[0]; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
</div> | |||
<!-- Contacto --> | |||
<div class="row mb-4"> | |||
<div class="col-md-6"> | |||
<label class="form-label" for="">E-mail*</label> | |||
<input name="email" type="email" class="form-control <?php if (session('errors.email')) : ?>is-invalid<?php endif ?>" readonly value="<?= $email ?>"> | |||
<input name="email" type="email" class="form-control <?php if (session('errors.email')) : ?>is-invalid<?php endif ?>" readonly value="<?= $email ?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Teléfono Fijo</label> | |||
<input name="telefono" type="text" class="form-control <?php if (session('errors.telefono')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('telefono')) echo old('telefono'); | |||
else if ($datos) echo $datos['telefono']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Celular*</label> | |||
<input name="celular" type="text" class="form-control <?php if (session('errors.celular')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('celular')) echo old('celular'); | |||
else if ($datos) echo $datos['celular']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
</div> | |||
<hr class="mb-5"> | |||
@@ -71,25 +71,25 @@ | |||
<label class="form-label" for="">Domicilio*</label> | |||
<input name="direccion" type="text" class="form-control <?php if (session('errors.direccion')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('direccion')) echo old('direccion'); | |||
else if ($datos) echo $datos['direccion']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-4"> | |||
<label class="form-label" for="">Colonia*</label> | |||
<input name="colonia" type="text" class="form-control <?php if (session('errors.colonia')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('colonia')) echo old('colonia'); | |||
else if ($datos) echo $datos['colonia']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-4"> | |||
<label class="form-label" for="">Municipio*</label> | |||
<input name="municipio" type="text" class="form-control <?php if (session('errors.municipio')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('municipio')) echo old('municipio'); | |||
else if ($datos) echo $datos['municipio']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-2"> | |||
<label class="form-label" for="">Código Postal*</label> | |||
<input name="cp" type="text" class="form-control <?php if (session('errors.cp')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('cp')) echo old('cp'); | |||
else if ($datos) echo $datos['cp']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
</div> | |||
<hr class="mb-5"> | |||
@@ -101,11 +101,11 @@ | |||
<label class="form-label" for="">Código de Estudiante*</label> | |||
<input name="codigo_estudiante" type="text" class="form-control" required value="<?php if (old('codigo_estudiante')) echo old('codigo_estudiante'); | |||
else if ($datos) echo $datos['codigo_estudiante']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-5"> | |||
<label class="form-label" for="">Centro Universitario*</label> | |||
<select name="idescuela" class="form-select <?php if (session('errors.idescuela')) : ?>is-invalid<?php endif ?>" required> | |||
<select name="idescuela" class="form-select <?php if (session('errors.idescuela')) : ?>is-invalid<?php endif ?>" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<option disabled selected value>---</option> | |||
<?php foreach ($escuelas as $escuela) : ?> | |||
<option value="<?= esc($escuela['idescuela']) ?>" <?php if (isset($datos) && $escuela['idescuela'] == $datos['idescuela']) echo 'selected="selected"'; ?>><?= esc($escuela['nombrecorto']) ?></option> | |||
@@ -116,17 +116,17 @@ | |||
<label class="form-label" for="">Carrera*</label> | |||
<input name="carrera" type="text" class="form-control <?php if (session('errors.carrera')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('carrera')) echo old('carrera'); | |||
else if ($datos) echo $datos['carrera']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-2"> | |||
<label class="form-label" for="">Grado*</label> | |||
<input name="grado" type="text" class="form-control <?php if (session('errors.grado')) : ?>is-invalid<?php endif ?>" required value="<?php if (old('grado')) echo old('grado'); | |||
else if ($datos) echo $datos['grado']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-5"> | |||
<label class="form-label">Turno*</label> | |||
<select name="turno" class="form-select <?php if (session('errors.turno')) : ?>is-invalid<?php endif ?>" required> | |||
<select name="turno" class="form-select <?php if (session('errors.turno')) : ?>is-invalid<?php endif ?>" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<option hidden disabled selected value>---</option> | |||
<option value="1" <?php if (isset($datos) && $datos['turno'] == 1) echo 'selected="selected"'; ?>>Matutino</option> | |||
<option value="2" <?php if (isset($datos) && $datos['turno'] == 2) echo 'selected="selected"'; ?>>Verspertino</option> | |||
@@ -140,7 +140,7 @@ | |||
<div class="row mb-4"> | |||
<div class="col-md-3"> | |||
<label class="form-label" for="">Elegiste Coparmex para realizar*</label> | |||
<select name="tipo" class="form-select <?php if (session('errors.tipo')) : ?>is-invalid<?php endif ?>" required> | |||
<select name="tipo" class="form-select <?php if (session('errors.tipo')) : ?>is-invalid<?php endif ?>" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<option hidden disabled selected value>---</option> | |||
<option value="1" <?php if (isset($datos) && $datos['tipo'] == 1) echo 'selected="selected"'; ?>>Servicio Social</option> | |||
<option value="2" <?php if (isset($datos) && $datos['tipo'] == 2) echo 'selected="selected"'; ?>>Prácticas Profesionales</option> | |||
@@ -149,7 +149,7 @@ | |||
<div class="col-md-6"> | |||
<!-- NO SE GUARDA CAMPO EN NING�N LUGAR --> | |||
<label class="form-label">Disponibilidad de horario*</label> | |||
<select name="horario" class="form-select"> | |||
<select name="horario" class="form-select" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<option value="1" <?php if (isset($datos) && $datos['horario'] == 1) echo 'selected="selected"'; ?>>08:00 am a 12:00 pm</option> | |||
<option value="2" <?php if (isset($datos) && $datos['horario'] == 2) echo 'selected="selected"'; ?>>09:00 am a 01:00 pm</option> | |||
<option value="3" <?php if (isset($datos) && $datos['horario'] == 3) echo 'selected="selected"'; ?>>01:00 pm a 05:00 pm</option> | |||
@@ -160,17 +160,17 @@ | |||
<label class="form-label" for="">Fecha programada de inicio*</label> | |||
<input name="fechainicio" type="date" class="form-control <?php if (session('errors.fechainicio')) : ?>is-invalid<?php endif ?>" value="<?php if (old('fechainicio')) echo old('fechainicio'); | |||
else if ($datos) echo explode(' ', $datos['fechainicio'])[0]; | |||
?>" required> | |||
?>" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-2"> | |||
<label class="form-label" for="">Horas Totales a Realizar*</label> | |||
<input name="horas_servicio" type="number" class="form-control <?php if (session('errors.horas_servicio')) : ?>is-invalid<?php endif ?>" min=1 required value="<?php if (old('horas_servicio')) echo old('horas_servicio'); | |||
else if ($datos) echo $datos['horas_servicio']; | |||
?>"> | |||
?>" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
</div> | |||
<div class="col-md-5 mt-md-2"> | |||
<label class="form-label">Departamento al cual fuiste asignado <span class="small">(Si aplica)</span></label> | |||
<select name="iddepartamento" class="form-select"> | |||
<select name="iddepartamento" class="form-select" <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<option selected value>---</option> | |||
<!-- Añadir opción: no sé --> | |||
<?php foreach ($departamentos as $departamento) : ?> | |||
@@ -179,19 +179,34 @@ | |||
</select> | |||
</div> | |||
</div> | |||
<div class=""> | |||
<input type="checkbox" required> | |||
<div class="<?= isset($revisar) ? 'd-none' : '' ?>"> | |||
<input type="checkbox" required <?= isset($revisar) ? 'disabled' : '' ?>> | |||
<label> | |||
Acepto el | |||
<a href="https://coparmexjal.org.mx/pdf/aviso-privacidad.pdf">aviso de privacidad</a> | |||
</label> | |||
</div> | |||
<div class="text-end"> | |||
<?php if ($datos) : ?> | |||
<a class="btn btn-danger me-3" href="<?= route_to('/') ?>">Cancelar</a> | |||
<?php endif ?> | |||
<button class="btn btn-primary" type="submit"><?= !empty($datos) ? 'Actualizar' : 'Enviar' ?></button> | |||
</div> | |||
<?php if (isset($revisar)) : ?> | |||
<!-- BOTONES PARA APROBAR / RECHAZAR SOLICITUD--> | |||
<div class="text-end"> | |||
<a href="" class="btn btn-primary">Regresar a lista</a> | |||
<a href="<?= route_to('admin_solicitud_rechazar', $id) ?>" class="btn btn-danger">Rechazar solicitud</a> | |||
<a href="<?= route_to('admin_solicitud_aprobar', $id) ?>" class="btn btn-success">Aprobar solicitud</a> | |||
</div> | |||
<?php else : ?> | |||
<!-- BOTONES PARA ENVIAR O EDITAR --> | |||
<div class="text-end"> | |||
<?php if ($datos) : ?> | |||
<a class="btn btn-danger me-3" href="<?= route_to('/') ?>">Cancelar</a> | |||
<?php endif ?> | |||
<button class="btn btn-primary" type="submit"><?= !empty($datos) ? 'Actualizar' : 'Enviar' ?></button> | |||
</div> | |||
<?php endif ?> | |||
</form> | |||
</div> | |||
</div> | |||
@@ -17,6 +17,24 @@ | |||
<?= $this->section('content') ?> | |||
<div class="row mb-5"> | |||
<!-- ENCUESTAS DISPONIBLES --> | |||
<?php if (isset($encuestas)) : ?> | |||
<div class="col-md-4"> | |||
<div class="card"> | |||
<div class="card-header"> | |||
Encuestas disponibles | |||
</div> | |||
<div class="card-body"> | |||
<div class="list-group list-group-flush"> | |||
<?php foreach ($encuestas as $encuesta) : ?> | |||
<a href="<?= route_to('encuesta', $encuesta['id']) ?>" class="list-group-item list-group-item-action"><?= $encuesta['title'] ?></a> | |||
<?php endforeach ?> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<?php endif ?> | |||
<!-- HORAS MENSUALES --> | |||
<div class="col-md-4 mb-5"> | |||
<div class="card"> | |||
@@ -25,7 +25,18 @@ | |||
<?= $this->include('templates/navbar') ?> | |||
<div class="container mt-4"> | |||
<?php if (session('msg')) : ?> | |||
<div class="alert alert-<?= session('msg')['type'] ?> alert-dismissible fade show" role="alert"> | |||
<?= session('msg')['body'] ?> | |||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> | |||
</div> | |||
<?php endif ?> | |||
<?= $this->renderSection('content') ?> | |||
</div> | |||
@@ -17,149 +17,12 @@ scratch. This page gets rid of all links and provides the needed markup only. | |||
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css"> | |||
<!-- Theme style --> | |||
<link rel="stylesheet" href="dist/css/adminlte.min.css"> | |||
</head> | |||
<body class="hold-transition sidebar-mini"> | |||
<div class="wrapper"> | |||
<!-- Navbar --> | |||
<nav class="main-header navbar navbar-expand navbar-white navbar-light"> | |||
<!-- Left navbar links --> | |||
<ul class="navbar-nav"> | |||
<li class="nav-item"> | |||
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a> | |||
</li> | |||
<li class="nav-item d-none d-sm-inline-block"> | |||
<a href="index3.html" class="nav-link">Home</a> | |||
</li> | |||
<li class="nav-item d-none d-sm-inline-block"> | |||
<a href="#" class="nav-link">Contact</a> | |||
</li> | |||
</ul> | |||
<!-- Right navbar links --> | |||
<ul class="navbar-nav ml-auto"> | |||
<!-- Navbar Search --> | |||
<li class="nav-item"> | |||
<a class="nav-link" data-widget="navbar-search" href="#" role="button"> | |||
<i class="fas fa-search"></i> | |||
</a> | |||
<div class="navbar-search-block"> | |||
<form class="form-inline"> | |||
<div class="input-group input-group-sm"> | |||
<input class="form-control form-control-navbar" type="search" placeholder="Search" aria-label="Search"> | |||
<div class="input-group-append"> | |||
<button class="btn btn-navbar" type="submit"> | |||
<i class="fas fa-search"></i> | |||
</button> | |||
<button class="btn btn-navbar" type="button" data-widget="navbar-search"> | |||
<i class="fas fa-times"></i> | |||
</button> | |||
</div> | |||
</div> | |||
</form> | |||
</div> | |||
</li> | |||
<!-- Messages Dropdown Menu --> | |||
<li class="nav-item dropdown"> | |||
<a class="nav-link" data-toggle="dropdown" href="#"> | |||
<i class="far fa-comments"></i> | |||
<span class="badge badge-danger navbar-badge">3</span> | |||
</a> | |||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right"> | |||
<a href="#" class="dropdown-item"> | |||
<!-- Message Start --> | |||
<div class="media"> | |||
<img src="dist/img/user1-128x128.jpg" alt="User Avatar" class="img-size-50 mr-3 img-circle"> | |||
<div class="media-body"> | |||
<h3 class="dropdown-item-title"> | |||
Brad Diesel | |||
<span class="float-right text-sm text-danger"><i class="fas fa-star"></i></span> | |||
</h3> | |||
<p class="text-sm">Call me whenever you can...</p> | |||
<p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p> | |||
</div> | |||
</div> | |||
<!-- Message End --> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item"> | |||
<!-- Message Start --> | |||
<div class="media"> | |||
<img src="dist/img/user8-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3"> | |||
<div class="media-body"> | |||
<h3 class="dropdown-item-title"> | |||
John Pierce | |||
<span class="float-right text-sm text-muted"><i class="fas fa-star"></i></span> | |||
</h3> | |||
<p class="text-sm">I got your message bro</p> | |||
<p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p> | |||
</div> | |||
</div> | |||
<!-- Message End --> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item"> | |||
<!-- Message Start --> | |||
<div class="media"> | |||
<img src="dist/img/user3-128x128.jpg" alt="User Avatar" class="img-size-50 img-circle mr-3"> | |||
<div class="media-body"> | |||
<h3 class="dropdown-item-title"> | |||
Nora Silvester | |||
<span class="float-right text-sm text-warning"><i class="fas fa-star"></i></span> | |||
</h3> | |||
<p class="text-sm">The subject goes here</p> | |||
<p class="text-sm text-muted"><i class="far fa-clock mr-1"></i> 4 Hours Ago</p> | |||
</div> | |||
</div> | |||
<!-- Message End --> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item dropdown-footer">See All Messages</a> | |||
</div> | |||
</li> | |||
<!-- Notifications Dropdown Menu --> | |||
<li class="nav-item dropdown"> | |||
<a class="nav-link" data-toggle="dropdown" href="#"> | |||
<i class="far fa-bell"></i> | |||
<span class="badge badge-warning navbar-badge">15</span> | |||
</a> | |||
<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right"> | |||
<span class="dropdown-header">15 Notifications</span> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item"> | |||
<i class="fas fa-envelope mr-2"></i> 4 new messages | |||
<span class="float-right text-muted text-sm">3 mins</span> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item"> | |||
<i class="fas fa-users mr-2"></i> 8 friend requests | |||
<span class="float-right text-muted text-sm">12 hours</span> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item"> | |||
<i class="fas fa-file mr-2"></i> 3 new reports | |||
<span class="float-right text-muted text-sm">2 days</span> | |||
</a> | |||
<div class="dropdown-divider"></div> | |||
<a href="#" class="dropdown-item dropdown-footer">See All Notifications</a> | |||
</div> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" data-widget="fullscreen" href="#" role="button"> | |||
<i class="fas fa-expand-arrows-alt"></i> | |||
</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a class="nav-link" data-widget="control-sidebar" data-slide="true" href="#" role="button"> | |||
<i class="fas fa-th-large"></i> | |||
</a> | |||
</li> | |||
</ul> | |||
</nav> | |||
<!-- /.navbar --> | |||
<!-- Main Sidebar Container --> | |||
<aside class="main-sidebar sidebar-dark-primary elevation-4"> | |||
<!-- Brand Logo --> | |||
@@ -176,61 +39,63 @@ scratch. This page gets rid of all links and provides the needed markup only. | |||
<img src="dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image"> | |||
</div> | |||
<div class="info"> | |||
<a href="#" class="d-block">Alexander Pierce</a> | |||
<a href="#" class="d-block">Administrador</a> | |||
</div> | |||
</div> | |||
<!-- SidebarSearch Form --> | |||
<div class="form-inline"> | |||
<div class="input-group" data-widget="sidebar-search"> | |||
<input class="form-control form-control-sidebar" type="search" placeholder="Search" aria-label="Search"> | |||
<div class="input-group-append"> | |||
<button class="btn btn-sidebar"> | |||
<i class="fas fa-search fa-fw"></i> | |||
</button> | |||
</div> | |||
</div> | |||
</div> | |||
<!-- Sidebar Menu --> | |||
<nav class="mt-2"> | |||
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false"> | |||
<!-- Add icons to the links using the .nav-icon class | |||
with font-awesome or any other icon font library --> | |||
<li class="nav-item menu-open"> | |||
<a href="#" class="nav-link active"> | |||
<i class="nav-icon fas fa-tachometer-alt"></i> | |||
<p> | |||
Starter Pages | |||
<i class="right fas fa-angle-left"></i> | |||
</p> | |||
<li class="nav-item"> | |||
<a href="" class="nav-link"> | |||
<i class="nav-icon fas fa-users"></i> | |||
Prestadores | |||
<i class="right fas fa-angle-left"></i> | |||
</a> | |||
<ul class="nav nav-treeview"> | |||
<li class="nav-item"> | |||
<a href="#" class="nav-link active"> | |||
<a href="#" class="nav-link"> | |||
<i class="far fa-circle nav-icon"></i> | |||
<p>Active Page</p> | |||
Activos | |||
</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a href="#" class="nav-link"> | |||
<a href="<?= route_to('admin_solicitudes') ?>" class="nav-link"> | |||
<i class="far fa-circle nav-icon"></i> | |||
<p>Inactive Page</p> | |||
Solicitudes | |||
</a> | |||
</li> | |||
</ul> | |||
</li> | |||
<li class="nav-item"> | |||
<li class="nav-item menu-open"> | |||
<a href="#" class="nav-link"> | |||
<i class="nav-icon fas fa-th"></i> | |||
<i class="nav-icon fas fa-chart-bar"></i> | |||
<p> | |||
Simple Link | |||
<span class="right badge badge-danger">New</span> | |||
Encuestas | |||
<i class="right fas fa-angle-left"></i> | |||
</p> | |||
</a> | |||
<ul class="nav nav-treeview"> | |||
<li class="nav-item"> | |||
<a href="<?= route_to('admin_encuesta_nueva') ?>" class="nav-link"> | |||
<i class="far fa-circle nav-icon"></i> | |||
<p>Nueva encuesta</p> | |||
</a> | |||
</li> | |||
<li class="nav-item"> | |||
<a href="<?= route_to('admin_encuestas') ?>" class="nav-link"> | |||
<i class="far fa-circle nav-icon"></i> | |||
<p>Lista</p> | |||
</a> | |||
</li> | |||
</ul> | |||
</li> | |||
</ul> | |||
</nav> | |||
<!-- /.sidebar-menu --> | |||
</div> | |||
<!-- /.sidebar --> | |||
@@ -238,18 +103,21 @@ scratch. This page gets rid of all links and provides the needed markup only. | |||
<!-- Content Wrapper. Contains page content --> | |||
<div class="content-wrapper"> | |||
<?php if (session('msg')) : ?> | |||
<div class="alert alert-<?= session('msg')['type'] ?> alert-dismissible fade show" role="alert"> | |||
<?= session('msg')['body'] ?> | |||
<button type="button" class="close" data-dismiss="alert" aria-label="Close"> | |||
<span aria-hidden="true">×</span> | |||
</button> | |||
</div> | |||
<?php endif ?> | |||
<!-- Content Header (Page header) --> | |||
<div class="content-header"> | |||
<div class="container-fluid"> | |||
<div class="row mb-2"> | |||
<div class="col-sm-6"> | |||
<h1 class="m-0"><?= isset($title) ? $title : 'Adminstrador' ?></h1> | |||
</div><!-- /.col --> | |||
<div class="col-sm-6"> | |||
<ol class="breadcrumb float-sm-right"> | |||
<li class="breadcrumb-item"><a href="#">Home</a></li> | |||
<li class="breadcrumb-item active">Starter Page</li> | |||
</ol> | |||
<h1 class="m-0"><?= isset($title) ? $title : '' ?></h1> | |||
</div><!-- /.col --> | |||
</div><!-- /.row --> | |||
</div><!-- /.container-fluid --> | |||
@@ -257,7 +125,7 @@ scratch. This page gets rid of all links and provides the needed markup only. | |||
<!-- /.content-header --> | |||
<!-- Main content --> | |||
<div class="content"> | |||
<div class="content pb-5"> | |||
<div class="container-fluid"> | |||
<?= $this->renderSection('content') ?> | |||
</div><!-- /.container-fluid --> | |||
@@ -276,15 +144,6 @@ scratch. This page gets rid of all links and provides the needed markup only. | |||
</aside> | |||
<!-- /.control-sidebar --> | |||
<!-- Main Footer --> | |||
<footer class="main-footer"> | |||
<!-- To the right --> | |||
<div class="float-right d-none d-sm-inline"> | |||
Anything you want | |||
</div> | |||
<!-- Default to the left --> | |||
<strong>Copyright © 2014-2021 <a href="<?= route_to('admin_home') ?>">COPARMEX</a>.</strong> All rights reserved. | |||
</footer> | |||
</div> | |||
<!-- ./wrapper --> | |||