$empleado["Segundo_Nombre"] = $_REQUEST["nombre2"]; $empleado["Apellido_Paterno"] = $_REQUEST["apellidop"]; $empleado["Apellido_Materno"] = $_REQUEST["apellidom"]; $empleado["Calle"] = $_REQUEST["calle"]; $empleado["Colonia"] = $_REQUEST["colonia"]; $empleado["NoCasa_Ext"] = $_REQUEST["exterior"]; $_REQUEST["interior"] == '' ? $empleado["NoCasa_Int"] = '0' : ($empleado["NoCasa_Int"] = $_REQUEST["interior"]); $empleado["Password"] = sha1($_REQUEST["pass"]); $posCiudad = intval($_REQUEST['ciudad']); $ciudad = ControladorEmpleado::obtenerCiudades()[$posCiudad]; $empleado["Ciudad"] = $ciudad->getAbreviatura(); $posTipo = intval($_REQUEST['tipo']); $tipo = ControladorEmpleado::obtenerTipoEmpleados()[$posTipo]; $empleado["Tipo_Empleado"] = $tipo->getAbreviatura(); $posTurno = intval($_REQUEST['turno']); $turno = ControladorEmpleado::obtenerTurnos()[$posTurno]; $empleado["Turno"] = $turno->getAbreviatura(); $posSucursal = intval($_REQUEST['sucursal']); $sucursal = ControladorSucursal::obtenerSucursales()[$posSucursal]; $empleado["ID_Sucursal"] = $sucursal->getID(); //Creación de un objeto del tipo empleado $obj = ControladorEmpleado::array_Empleado($empleado); if ($_REQUEST["accion"] == 'Agregar') { $posible = ControladorEmpleado::insertarEmpleado($obj); if ($posible) { echo 'OK'; } else { echo 'KO'; } } else { if ($_REQUEST["accion"] == 'Modificar') {
ControladorBaseDatos::validarSesionIniciada('NuevoEmpleado'); $plantilla = file_get_contents(__DIR__ . "/Plantillas/plantillaAgregacionEmpleados.html"); $plantilla = str_replace('|header|', DesplegadorInterfaz::getHeader(), $plantilla); $plantilla = str_replace('|operacion|', 'Agregar', $plantilla); $plantilla = str_replace('|footer|', DesplegadorInterfaz::getFooter(), $plantilla); //Cargar ciudades $ciudades = ControladorEmpleado::obtenerCiudades(); $ciudadesS = ""; $ciudadesS = $ciudadesS . '<select id="aCiudad">'; foreach ($ciudades as $key => $value) { $ciudadesS = $ciudadesS . "<option id=calidad{$key}>" . $value->getNombre() . "</option>"; } $ciudadesS = $ciudadesS . "</select>"; $plantilla = str_replace('|ciudades|', $ciudadesS, $plantilla); //Cargar turnos $turnos = ControladorEmpleado::obtenerTurnos(); $turnosS = ""; $turnosS = $turnosS . '<select id="aTurno">'; foreach ($turnos as $key => $value) { $turnosS = $turnosS . "<option id=calidad{$key}>" . $value->getNombre() . "</option>"; } $turnosS = $turnosS . "</select>"; $plantilla = str_replace('|turnos|', $turnosS, $plantilla); //Cargar los tipos $tipos = ControladorEmpleado::obtenerTipoEmpleados(); $tiposS = ""; $tiposS = $tiposS . '<select id="aTipo">'; foreach ($tipos as $key => $value) { $tiposS = $tiposS . "<option id=calidad{$key}>" . $value->getNombre() . "</option>"; } $tiposS = $tiposS . "</select>";