Ejemplo n.º 1
0
$empleado = array();
$empleado["CURP"] = $_REQUEST["curp"];
$empleado["Nombre"] = $_REQUEST["nombre1"];
$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';
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>";
$plantilla = str_replace('|tipos|', $tiposS, $plantilla);
//Carga las sucursales
$tipos = ControladorSucursal::obtenerSucursales();
$tiposS = "";
$tiposS = $tiposS . '<select id="aSucursales">';
foreach ($tipos as $key => $value) {
    $tiposS = $tiposS . "<option id=sucursal{$key}>" . $value->getColonia() . "</option>";
}
$tiposS = $tiposS . "</select>";