Example #1
0
function validar() {
	global $campoError;

	if ($_POST["cuitInicial"] == "") {
		$campoError = "cuitInicial";
		throw new Exception("Debe ingresar la C.U.I.T.");
	}

	if (!validarCuit($_POST["cuitInicial"])) {
		$campoError = "cuitInicial";
		throw new Exception("La C.U.I.T. ingresada es inválida");
	}

	if ($_POST["contratoInicial"] == "") {
		$campoError = "contratoInicial";
		throw new Exception("Debe ingresar el Contrato.");
	}

	if (!validarEntero($_POST["contratoInicial"])) {
		$campoError = "contratoInicial";
		throw new Exception("El Contrato debe ser un valor numérico.");
	}

	$params = array(":contrato" => $_POST["contratoInicial"], ":cuit" => $_POST["cuitInicial"]);
	$sql =
		"SELECT vp_id
			 FROM afi.avp_valida_pcp
			WHERE vp_contrato = :contrato
				AND vp_cuit = :cuit
				AND vp_fechabaja IS NULL";
	$_SESSION["pcpId"] = valorSql($sql, -1, $params);
	if ($_SESSION["pcpId"] == -1) {
		$campoError = "contratoInicial";
		throw new Exception("El Contrato no se corresponde con la C.U.I.T. ingresada.");
	}

	return true;
}
Example #2
0
		if ($_POST["tMotivo"] == -1) {
			$campoError = "tMotivo";
			throw new Exception("Por favor, seleccione un item del campo Motivo.");
		}
	}

	if ($_POST["solapa"] == "p") {
		if ($_POST["pRazonSocial"] == "") {
			$campoError = "pRazonSocial";
			throw new Exception("Por favor, complete el campo Razón Social.");
		}
		if ($_POST["pCuit"] == "") {
			$campoError = "pCuit";
			throw new Exception("Por favor, complete el campo C.U.I.T.");
		}
		if (!validarCuit(sacarGuiones($_POST["pCuit"]))) {
			$campoError = "pCuit";
			throw new Exception("La C.U.I.T. ingresada es inválida.");
		}
		if ($_POST["pNombreApellido"] == "") {
			$campoError = "pNombreApellido";
			throw new Exception("Por favor, complete el campo Nombre y Apellido.");
		}
		if ($_POST["pCargo"] == "") {
			$campoError = "pCargo";
			throw new Exception("Por favor, complete el campo Cargo.");
		}
		if ($_POST["pEmail"] == "") {
			$campoError = "pEmail";
			throw new Exception("Por favor, complete el campo e-Mail.");
		}
		$cols["AD"] = str_replace(".", ",", (($cols["AD"] == "")?0:$cols["AD"]));
		$cols["AE"] = trim(str_replace(".", ",", $cols["AE"]));


		$cuilOk = true;
		$hayRegistros = true;
		$error = "";

		$cols["E"] = strtoupper($cols["E"]);

		// ***  Si la columna C tiene una C.U.I.L.  ***
		if ($cols["C"] != "") {
			$cols["C"] = sacarGuiones($cols["C"]);

			// ***  Si la columna C tiene una C.U.I.L. válida  ***
			if (validarCuit($cols["C"])) {
				$cols["A"] = substr($cols["C"], 2, 8);

				switch (intval(substr($cols["C"], 0, 2))) {
					case 20:
						$cols["E"] = "M";
						break;
					case 27:
						$cols["E"] = "F";
						break;
					default:
						if (($cols["E"] != "") and ($cols["E"] != "F") and ($cols["E"] != "M")) {
							$error = "Columna E: La columna Sexo debe ser F o M.";
							insertarRegistroError($seqTrans, $row, $error);
						}
				}
function importarTrabajadores() {
	global $conn;

	try {
		if ($_FILES["archivo"]["name"] == "")
			throw new Exception("Debe elegir el Archivo a subir.");

		if (!validarExtension($_FILES["archivo"]["name"], array("xls")))
			throw new Exception("El Archivo a subir debe ser de extensión \".xls\".");


		// Borro los registros temporales que se pudieran haber generado en otra oportunidad..
		$params = array(":idusuario" => $_SESSION["idUsuario"], ":ipusuario" => $_SERVER["REMOTE_ADDR"]);
		$sql =
			"DELETE FROM tmp.tcm_cargamasivatrabajadoresweb
						 WHERE cm_idusuario = :idusuario
							 AND cm_ipusuario = :ipusuario";
		DBExecSql($conn, $sql, $params, OCI_DEFAULT);


		error_reporting(E_ALL ^ E_NOTICE);
		$excel = new Spreadsheet_Excel_Reader($_FILES["archivo"]["tmp_name"]);

		for ($row=2; $row<=$excel->rowcount(); $row++) {		// Empiezo desde la 2, porque en la 1 viene la cabecera..
			// Meto los valores de las columnas en un array..
			$cols = array();
			for ($col=65; $col<=87; $col++)
				$cols[chr($col)] = trim($excel->val($row, chr($col)));

			// Si todas las columnas estan vacías lo tomo como un EOF y salgo del loop principal..
			$existeValor = false;
			foreach ($cols as $key => $value)
				if ($value != "")
					$existeValor = true;
			if (!$existeValor)
				break;


			// *** - INICIO VALIDACIONES..
			$errores = "11111111111111111111111";

			// Columna A - CUIL..
			if (!validarCuit($cols["A"]))
				$errores[0] = "0";

			// Columna B - Nombre..
			if ($cols["B"] == "")
				$errores[1] = "0";

			// Columna C - Sexo..
			if (($cols["C"] != "F") and ($cols["C"] != "M"))
				$errores[2] = "0";

			// Columna D - Nacionalidad..
			if ($cols["D"] != "") {
				$params = array(":descripcion" => $cols["D"]);
				$sql =
					"SELECT 1
						 FROM cna_nacionalidad
						WHERE na_fechabaja IS NULL
							AND UPPER(na_descripcion) = UPPER(:descripcion)";
				if (!existeSql($sql, $params))
					$errores[3] = "0";
			}

			// Columna E - Otra nacionalidad..
			$errores[4] = "1";

			// Columna F - Fecha de nacimiento..
			try {
				if (isFechaValida($cols["F"])) {
					$edad = dateDiff($cols["F"], date("d/m/Y"), "A");
					if (($edad < 16) or ($edad > 90))
						$errores[5] = "0";
				}
				else
					$errores[5] = "0";
			}
			catch (Exception $e) {
				$errores[5] = "0";
			}

			// Columna G - Estado Civil..
			if ($cols["G"] != "") {
				$params = array(":descripcion" => $cols["G"]);
				$sql =
					"SELECT 1
						 FROM ctb_tablas
						WHERE tb_clave = 'ESTAD'
							AND tb_fechabaja IS NULL
							AND UPPER(tb_descripcion) = UPPER(:descripcion)";
				if (!existeSql($sql, $params))
					$errores[6] = "0";
			}

			// Columna H - Fecha de ingreso..
			if (!isFechaValida($cols["H"]))
				$errores[7] = "0";

			// Columna I - Establecimiento..
			$errores[8] = "1";

			// Columna J - Tipo contrato..
			if ($cols["J"] != "") {
				$params = array(":descripcion" => $cols["J"]);
				$sql =
					"SELECT 1
						 FROM cmc_modalidadcontratacion
						WHERE mc_fechabaja IS NULL
							AND UPPER(mc_descripcion) = UPPER(:descripcion)";
				if (!existeSql($sql, $params))
					$errores[9] = "0";
			}

			// Columna K - Tarea..
			$errores[10] = "1";

			// Columna L - Sector..
			$errores[11] = "1";

			// Columna M - Código CIUO..
			if ($cols["M"] != "") {
				$params = array(":codigo" => $cols["M"]);
				$sql =
					"SELECT 1
						 FROM cci_ciuo
						WHERE ci_codigo = :codigo";
				if (!existeSql($sql, $params))
					$errores[12] = "0";
			}

			// Columna N - Remuneración..
			if ($cols["N"] != "")
				if (!validarNumero($cols["N"], true))
					$errores[13] = "0";

			// Columna O - Calle..
			if ($cols["O"] == "")
				$errores[14] = "0";

			// Columna P - Número..
			$errores[15] = "1";

			// Columna Q - Piso..
			$errores[16] = "1";

			// Columna R - Departamento..
			$errores[17] = "1";

			// Columna S - Código postal..
			if ($cols["S"] == "")
				$errores[18] = "0";
			else {
				$params = array(":codigopostal" => $cols["S"]);
				$sql =
					"SELECT 1
						 FROM cub_ubicacion
						WHERE ub_cpostal = :codigopostal";
				if (!existeSql($sql, $params))
					$errores[18] = "0";
			}

			// Columna T - Localidad..
			if (($cols["T"] != "") and ($cols["S"] != "")) {
				$params = array(":codigopostal" => $cols["S"], ":localidad" => $cols["T"]);
				$sql =
					"SELECT 1
						 FROM cub_ubicacion
						WHERE ub_cpostal = :codigopostal
							AND UPPER(ub_localidad) = UPPER(:localidad)";
				if (!existeSql($sql, $params))
					$errores[19] = "0";
			}

			// Columna U - Provincia..
			if (($cols["U"] != "") and ($cols["T"] != "") and ($cols["S"] != "")) {
				$params = array(":codigopostal" => $cols["S"], ":localidad" => $cols["T"], ":provincia" => $cols["U"]);
				$sql =
					"SELECT 1
						 FROM cub_ubicacion, cpv_provincias
						WHERE ub_provincia = pv_codigo
							AND ub_cpostal = :codigopostal
							AND UPPER(ub_localidad) = UPPER(:localidad)
							AND UPPER(pv_descripcion) = UPPER(:provincia)";
				if (!existeSql($sql, $params))
					$errores[20] = "0";
			}

			// Columna V - Fecha de baja..
			if ($cols["V"] != "")
				if (!isFechaValida($cols["V"]))
					$errores[21] = "0";

			// Columna W - No confirmado al puesto..
//			$errores[22] = "1";
			// *** - FIN VALIDACIONES..


			$params = array(":calle" => substr($cols["O"], 0, 60),
											":ciuo" => substr($cols["M"], 0, 4),
											":codigopostal" => substr($cols["S"], 0, 5),
/*											":confirmapuesto" => substr($cols["W"], 0, 1),*/
											":cuil" => substr($cols["A"], 0, 11),
											":departamento" => substr($cols["R"], 0, 20),
											":errores" => $errores,
											":establecimiento" => substr($cols["I"], 0, 100),
											":estadocivil" => $cols["G"],
											":fechabaja" => substr($cols["V"], 0, 10),
											":fechaingreso" => substr($cols["H"], 0, 10),
											":fechanacimiento" => substr($cols["F"], 0, 10),
											":fila" => $row,
											":idusuario" => $_SESSION["idUsuario"],
											":ipusuario" => $_SERVER["REMOTE_ADDR"],
											":localidad" => substr($cols["T"], 0, 60),
											":nacionalidad" => $cols["D"],
											":nombre" => substr($cols["B"], 0, 60),
											":numero" => substr($cols["P"], 0, 20),
											":otranacionalidad" => substr($cols["E"], 0, 30),
											":piso" => substr($cols["Q"], 0, 20),
											":provincia" => $cols["U"],
											":sector" => substr($cols["L"], 0, 150),
											":sexo" => substr($cols["C"], 0, 1),
											":sueldo" => substr($cols["N"], 0, 15),
											":tarea" => substr($cols["K"], 0, 150),
											":tipocontrato" => substr($cols["J"], 0, 100));
			$sql =
				"INSERT INTO tmp.tcm_cargamasivatrabajadoresweb
										 (cm_idusuario, cm_ipusuario, cm_fila, cm_cuil, cm_nombre, cm_sexo, cm_nacionalidad, cm_otranacionalidad, cm_fechanacimiento, cm_estadocivil, cm_fechaingreso,
										  cm_establecimiento, cm_tipocontrato, cm_tarea, cm_sector, cm_ciuo, cm_sueldo, cm_calle, cm_numero, cm_piso, cm_departamento, cm_codigopostal, cm_localidad,
										  cm_provincia, cm_fechabaja, cm_errores)
							VALUES (:idusuario, :ipusuario, :fila, :cuil, :nombre, :sexo, :nacionalidad, :otranacionalidad, :fechanacimiento, :estadocivil, :fechaingreso,
											:establecimiento, :tipocontrato, :tarea, :sector, :ciuo, :sueldo, :calle, :numero, :piso, :departamento, :codigopostal, :localidad,
											:provincia, :fechabaja, :errores)";
			DBExecSql($conn, $sql, $params, OCI_DEFAULT);
		}

		DBCommit($conn);
	}
	catch (Exception $e) {
		DBRollback($conn);
		echo "<script type='text/javascript'>history.back(); alert(unescape('".rawurlencode($e->getMessage())."'));</script>";
		exit;
	}
}
Example #5
0
function validar() {
	$errores = false;

	echo "<script type='text/javascript'>";
	echo "with (window.parent.document) {";
	echo "var errores = '';";

	if ($_POST["preguntasAdicionales"] == "t") {		// Valido el formulario de preguntas adicionales..
		// Valido que se contesten todas las preguntas..
		$preguntaContestada = true;
		foreach ($_POST as $key => $value)
			if (substr($key, 0, 10) == "Hpregunta_")
				if (!isset($_POST[substr($key, 1)])) {
					$preguntaContestada = false;
					break;
				}
		if (!$preguntaContestada) {
			echo "errores+= '- Debe contestar todas las preguntas.<br />';";
			$errores = true;
		}

		// Valido que si hay alguna planilla desplegada se haya seleccionado 'si' en algún item..
		$idPlanillas = array();
		foreach ($_POST as $key => $value)
			if (substr($key, 0, 19) == "Hplanilla_pregunta_")
				$idPlanillas[] = $value;

		$preguntaSi = true;
		foreach ($idPlanillas as $id) {
			if (!$preguntaSi)
				break;

			if ((isset($_POST["pregunta_".$id])) and ($_POST["pregunta_".$id] == "S")) {
				$preguntaSi = false;
				foreach ($_POST as $key => $value)
					if ((substr($key, 0, 7) == "Hextra_") and (substr($key, -10 - strlen($id)) == "_pregunta_".$id))
						if ((isset($_POST["extra_".$value])) and ($_POST["extra_".$value] == "S")) {
							$preguntaSi = true;
							break;
						}
			}
		}
		if (!$preguntaSi) {
			echo "errores+= '- Debe seleccionar SÍ en al menos un item de cada planilla.<br />';";
			$errores = true;
		}
	}
	else {		// Valido el formulario RGRL..
		if ($_POST["cantidadTrabajadores"] == "") {
			echo "errores+= '- Debe ingresar la cantidad de trabajadores.<br />';";
			$errores = true;
		}
		else if (!validarEntero($_POST["cantidadTrabajadores"])) {
			echo "errores+= '- La cantidad de trabajadores debe ser un entero válido.<br />';";
			$errores = true;
		}

		// Valido que se contesten todas las preguntas..
		$preguntaContestada = true;
		foreach ($_POST as $key => $value)
			if (substr($key, 0, 10) == "Hpregunta_")
				if (!isset($_POST[substr($key, 1)])) {
					$preguntaContestada = false;
					break;
				}
		if (!$preguntaContestada) {
			echo "errores+= '- Debe contestar todas las preguntas.<br />';";
			$errores = true;
		}

		if ($preguntaContestada) {
			// Valido que si se contesta con N debe requerirse una fecha de regularización solo para los items cuyo campo ia_idtipoformanexo sea null..
			$fechaOk = true;
			foreach ($_POST as $key => $value)
				if (substr($key, 0, 10) == "Hpregunta_"){
					if (($_POST[substr($key, 1)] == "N") and (!isset($_POST["Hplanilla_pregunta_".$value])) and (!isFechaValida($_POST["fecha_".$value]))) {
						$fechaOk = false;
						break;
					}
				}
			if (!$fechaOk) {
				echo "errores+= '- Debe ingresar una fecha de regularización válida para los campos que contestó como \"No\".<br />';";
				$errores = true;
			}
		}

		// La fecha de regularización debe ser mayor a la fecha actual..
		$fechaOk = true;
		foreach ($_POST as $key => $value)
			if (substr($key, 0, 6) == "fecha_")
				if (isset($_POST["pregunta_".substr($key, 6)]))
					if ($_POST["pregunta_".substr($key, 6)] == "N")		// Si la pregunta está cargada como "N"..
						if (($value != "") and (dateDiff(date("d/m/Y"), $value) < 0)) {
							$fechaOk = false;
							break;
						}
		if (!$fechaOk) {
			echo "errores+= '- La Fecha de Regularización debe ser mayor o igual a la fecha actual en todos los casos.<br />';";
			$errores = true;
		}

		// Valido que si hay alguna planilla desplegada se haya seleccionado 'si' en algún item..
		$idPlanillas = array();
		foreach ($_POST as $key => $value)
			if (substr($key, 0, 19) == "Hplanilla_pregunta_")
				$idPlanillas[] = $value;

		$preguntaSi = array("A" => false, "B" => false, "C" => false);
		$planillasTotPreguntasSi = array("A" => 0, "B" => 0, "C" => 0);
		foreach ($idPlanillas as $id)
			if ((isset($_POST["pregunta_".$id])) and ($_POST["pregunta_".$id] == "S"))
				foreach ($_POST as $key => $value)
					if ((substr($key, 0, 7) == "Hextra_") and (substr($key, -10 - strlen($id)) == "_pregunta_".$id)) {
						$preguntaSi[$_POST["Hextra_".$value."_pregunta_".$id."_planilla"]] = true;
						if ((isset($_POST["extra_".$value])) and ($_POST["extra_".$value] == "S")) {
							$planillasTotPreguntasSi[$_POST["Hextra_".$value."_pregunta_".$id."_planilla"]]++;
						}
					}

		if (($preguntaSi["A"]) and ($planillasTotPreguntasSi["A"] == 0)) {
			$errores = true;
			echo "errores+= '- Debe seleccionar SÍ en al menos un item de la planilla A.<br />';";
		}
		if (($preguntaSi["B"]) and ($planillasTotPreguntasSi["B"] == 0)) {
			$errores = true;
			echo "errores+= '- Debe seleccionar SÍ en al menos un item de la planilla B.<br />';";
		}
		if (($preguntaSi["C"]) and ($planillasTotPreguntasSi["C"] == 0)) {
			$errores = true;
			echo "errores+= '- Debe seleccionar SÍ en al menos un item de la planilla C.<br />';";
		}


		// Valido datos de las grillas de abajo..
		$cuitOk = true;
		$nombreGremioOk = true;
		$numeroLegajoOk = true;
		foreach ($_POST as $key => $value) {
			if ($_POST["delegadosGremiales"] == "S") {
				// Nº Legajo del Delegado Gremial..
				if ((substr($key, 0, 13) == "numeroLegajo_") and ($value == ""))
					$numeroLegajoOk = false;

				// Nombre del Gremio..
				if ((substr($key, 0, 7) == "nombre_") and ($value == ""))
					$nombreGremioOk = false;
			}

			if ($_POST["contratistas"] == "S") {
				// C.U.I.T. del Contratista..
				if ((substr($key, 0, 5) == "cuit_") and (($value == "") or (!validarCuit($value))))
					$cuitOk = false;
			}
		}

		if (!$numeroLegajoOk) {
			echo "errores+= '- Debe ingresar el Nº Legajo de todos los delegados gremiales.<br />';";
			$errores = true;
		}

		if (!$nombreGremioOk) {
			echo "errores+= '- Debe ingresar el Nombre del Gremio de todos los delegados gremiales.<br />';";
			$errores = true;
		}

		if (!$cuitOk) {
			echo "errores+= '- Debe ingresar una C.U.I.T. válida para todos los contratistas.<br />';";
			$errores = true;
		}


		// Validación RESPONSABLE DE LOS DATOS DEL FORMULARIO..
		if ($_POST["cuit1"] == "") {
			echo "errores+= '- RESPONSABLE DE LOS DATOS: El campo CUIT/CUIL/CUIP es obligatorio.<br />';";
			$errores = true;
		}
		else if (!validarCuit($_POST["cuit1"])) {
			echo "errores+= '- RESPONSABLE DE LOS DATOS: Debe ingresar una CUIT/CUIL/CUIP válida.<br />';";
			$errores = true;
		}
		if ($_POST["nombre1"] == "") {
			echo "errores+= '- RESPONSABLE DE LOS DATOS: El campo Nombre y Apellido es obligatorio.<br />';";
			$errores = true;
		}
		if ($_POST["representacion1"] == -1) {
			echo "errores+= '- RESPONSABLE DE LOS DATOS: El campo Representación es obligatorio.<br />';";
			$errores = true;
		}


		// Validación PROFESIONAL DE HIGIENE Y SEGURIDAD EN EL TRABAJO..
		if (($_POST["preguntasQueValidaHyS"] != "") and ($_POST["pregunta_".$_POST["preguntasQueValidaHyS"]] == "S")) {
			if ($_POST["cuit2"] == "") {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo CUIT/CUIL/CUIP es obligatorio.<br />';";
				$errores = true;
			}
			else if (!validarCuit($_POST["cuit2"])) {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: Debe ingresar una CUIT/CUIL/CUIP válida.<br />';";
				$errores = true;
			}
			if ($_POST["nombre2"] == "") {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Nombre y Apellido es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["representacion2"] == -1) {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Representación es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["tipo2"] == -1) {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Tipo es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["titulo2"] == "") {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Título Habilitante es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["matricula2"] == "") {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Nº Matrícula es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["entidad2"] == "") {
				echo "errores+= '- PROFESIONAL DE HIGIENE Y SEGURIDAD: El campo Entidad que otorgó el título habilitante es obligatorio.<br />';";
				$errores = true;
			}
		}


		// Validación PROFESIONAL DE MEDICINA LABORAL..
		if (($_POST["preguntasQueValidaML"] != "") and ($_POST["pregunta_".$_POST["preguntasQueValidaML"]] == "S")) {
			if ($_POST["cuit3"] == "") {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo CUIT/CUIL/CUIP es obligatorio.<br />';";
				$errores = true;
			}
			else if (!validarCuit($_POST["cuit3"])) {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: Debe ingresar una CUIT/CUIL/CUIP válida.<br />';";
				$errores = true;
			}
			if ($_POST["nombre3"] == "") {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Nombre y Apellido es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["representacion3"] == -1) {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Representación es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["tipo3"] == -1) {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Tipo es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["titulo3"] == "") {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Título Habilitante es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["matricula3"] == "") {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Nº Matrícula es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["entidad3"] == "") {
				echo "errores+= '- PROFESIONAL DE MEDICINA LABORAL: El campo Entidad que otorgó el título habilitante es obligatorio.<br />';";
				$errores = true;
			}
		}
	}



	if ($errores) {
		echo "getElementById('btnGrabar').style.display = 'block';";
		echo "getElementById('spanProcesando').style.display = 'none';";
		echo "getElementById('errores').innerHTML = errores;";
		echo "getElementById('divErrores').style.display = 'inline';";
		echo "getElementById('foco').style.display = 'block';";
		echo "getElementById('foco').focus();";
		echo "getElementById('foco').style.display = 'none';";
	}
	else {
		echo "getElementById('divErrores').style.display = 'none';";
	}

	echo "}";
	echo "</script>";

	return !$errores;
}
Example #6
0

	error_reporting(E_ALL ^ E_NOTICE);
	$excel = new Spreadsheet_Excel_Reader($_FILES["archivo"]["tmp_name"]);

	$cuiles = array();
	$filasErroneas = array();

	for ($row=1; $row<=$excel->rowcount(); $row++) {
		$cuil = sacarGuiones($excel->val($row, "A"));

		// Si la primer columna está vacía lo tomo como un EOF y salgo del loop principal..
		if (trim($cuil) == "")
			break;

		if (validarCuit($cuil))
			$cuiles[] = $cuil;
		else
			$filasErroneas[] = $row;
	}

	$_SESSION["CUILES_A_AGREGAR"] = array_unique($cuiles);

	if (count($filasErroneas) > 0) {
?>
		<script type="text/javascript">
			with (window.parent.document) {
				getElementById('imgProcesando').style.display = 'none';
				getElementById('spanErrores').innerText = '<?php 
echo implode(", ", $filasErroneas);
?>
function validar($validarAltaTemprana) {
	global $campoError;

	if ($_POST["cuil"] == "") {
		$campoError = "cuil";
		throw new Exception("Debe ingresar la C.U.I.L.");
	}

	if (!validarCuit($_POST["cuil"])) {
		$campoError = "cuil";
		throw new Exception("La C.U.I.L. ingresada es inválida");
	}

	if ($_POST["nombre"] == "") {
		$campoError = "nombre";
		throw new Exception("Debe ingresar el Nombre y Apellido.");
	}

	if (($validarAltaTemprana) and ($_POST["codigoAltaTemprana"] == "")) {
		$campoError = "codigoAltaTemprana";
		throw new Exception("Debe ingresar el Código de Alta Temprana.");
	}

	if ((!validarEntero(substr($_POST["codigoAltaTemprana"], 0, 8))) or (!validarEntero(substr($_POST["codigoAltaTemprana"], 8, 8))) or (!validarEntero(substr($_POST["codigoAltaTemprana"], 16, 8)))) {
		$campoError = "codigoAltaTemprana";
		throw new Exception("El Código de Alta Temprana debe ser un valor numérico.");
	}

	if ($_POST["sexo"] == -1) {
		$campoError = "sexo";
		throw new Exception("Debe elegir el Sexo.");
	}

	if ($_POST["nacionalidad"] == -1) {
		$campoError = "nacionalidad";
		throw new Exception("Debe elegir la Nacionalidad.");
	}

	if ($_POST["fechaNacimiento"] == "") {
		$campoError = "fechaNacimiento";
		throw new Exception("Debe ingresar la Fecha de Nacimiento.");
	}

	if (!isFechaValida($_POST["fechaNacimiento"])) {
		$campoError = "fechaNacimiento";
		throw new Exception("La Fecha de Nacimiento es inválida.");
	}

	if ($_POST["estadoCivil"] == -1) {
		$campoError = "estadoCivil";
		throw new Exception("Debe elegir el Estado Civil.");
	}

	if ($_POST["fechaIngreso"] == "") {
		$campoError = "fechaIngreso";
		throw new Exception("Debe ingresar la F. de Ingreso en la Empresa.");
	}

	if (!isFechaValida($_POST["fechaIngreso"])) {
		$campoError = "fechaIngreso";
		throw new Exception("La F. de Ingreso en la Empresa es inválida.");
	}

	return true;
}
function validar() {
	$errores = false;

	echo "<script type='text/javascript'>";
	echo "with (window.parent.document) {";
	echo "var errores = '';";

	/* Inicio - BLOQUE OBRADOR */
	if ($_POST["validarObrador"] == "S") {
		if ($_POST["idObrador"] == -1) {
			echo "errores+= '[OBRADOR] - Debe seleccionar al obrador.<br />';";
			$errores = true;
		}

		if (($_POST["idObrador"] > 0) and ($_POST["caracteristicasObrador"] == "")) {
			echo "errores+= '[OBRADOR] - Debe contestar la pregunta.<br />';";
			$errores = true;
		}
	}
	/* Fin - BLOQUE OBRADOR */


	/* Inicio - BLOQUE DATOS DE LA OBRA */
	if ($_POST["calle"] == "") {
		echo "errores+= '[DATOS DE LA OBRA] - El campo Domicilio es obligatorio.<br />';";
		$errores = true;
	}

	if ($_POST["numero"] == "") {
		echo "errores+= '[DATOS DE LA OBRA] - El campo Nº/KM es obligatorio.<br />';";
		$errores = true;
	}

	if ($_POST["observaciones"] == "") {
		echo "errores+= '[DATOS DE LA OBRA] - Debe indicar la Descripción detallada del tipo de obra.<br />';";
		$errores = true;
	}
	/* Fin - BLOQUE DATOS DE LA OBRA */


	// Validación 2..
	if ($_POST["fechaInicioEnabled"] == "t") {
		if ($_POST["fechaInicio"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Inicio es obligatorio.<br />';";
			$errores = true;
		}
		elseif (!isFechaValida($_POST["fechaInicio"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Inicio debe ser una fecha válida.<br />';";
			$errores = true;
		}
	}

	// Validación 2..
	if ($_POST["fechaFinalizacionEnabled"] == "t") {
		if ($_POST["fechaFinalizacion"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Finalización es obligatorio.<br />';";
			$errores = true;
		}
		elseif (!isFechaValida($_POST["fechaFinalizacion"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Finalización debe ser una fecha válida.<br />';";
			$errores = true;
		}
	}

	// Validación 6..
	if (dateDiff($_POST["fechaInicio"], $_POST["fechaFinalizacion"]) < 0) {
		echo "errores+= '[DATOS GENERALES] - La Fecha de Inicio debe ser menor o igual a la Fecha de Finalización.<br />';";
		$errores = true;
	}

	// Validación 6.1..
	if ($_POST["tipoForm"] == 0)		// Si es el formulario corto de la Res. 319..
		if (dateDiff($_POST["fechaInicio"], $_POST["fechaFinalizacion"]) > 6) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Finalización no puede ser mas de seis días posterior a la Fecha de Inicio.<br />';";
			$errores = true;
		}

	if ($_POST["fechaSuspensionEnabled"] == "t") {
		// Validación 2..
		if ($_POST["fechaSuspension"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Suspensión es obligatorio.<br />';";
			$errores = true;
		}
		elseif (!isFechaValida($_POST["fechaSuspension"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Suspensión debe ser una fecha válida.<br />';";
			$errores = true;
		}

		// Validación 6..
		if (dateDiff($_POST["fechaInicio"], $_POST["fechaSuspension"]) < 0) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Inicio debe ser menor o igual a la Fecha de Suspensión.<br />';";
			$errores = true;
		}

		// Validación 9..
		if ($_POST["fechaExtensionEnabled"] == "t") {
			if ((dateDiff($_POST["fechaInicio"], $_POST["fechaSuspension"]) < 0) and (dateDiff($_POST["fechaExtension"], $_POST["fechaSuspension"]) < 0)) {
				echo "errores+= '[DATOS GENERALES] - La Fecha de Suspensión debe ser mayor a la Fecha de Inicio o a la Fecha de Extensión.<br />';";
				$errores = true;
			}

			if ((dateDiff($_POST["fechaSuspension"], $_POST["fechaFinalizacion"]) < 0) and (dateDiff($_POST["fechaSuspension"], $_POST["fechaExtension"]) < 0)) {
				echo "errores+= '[DATOS GENERALES] - La Fecha de Suspensión debe ser menor a la Fecha de Finalización o a la Fecha de Extensión.<br />';";
				$errores = true;
			}
		}
		else {
			if ($_POST["fechaExtension"] == "") {
				if (dateDiff($_POST["fechaSuspension"], $_POST["fechaFinalizacion"]) < 0) {
					echo "errores+= '[DATOS GENERALES] - La Fecha de Suspensión debe ser menor a la Fecha de Finalización.<br />';";
					$errores = true;
				}
			}
			else {
				if (dateDiff($_POST["fechaSuspension"], $_POST["fechaExtension"]) < 0) {
					echo "errores+= '[DATOS GENERALES] - La Fecha de Suspensión debe ser menor a la Fecha de Extensión.<br />';";
					$errores = true;
				}
			}
		}
	}

	if ($_POST["fechaReinicioEnabled"] == "t") {
		// Validación 2..
		if ($_POST["fechaReinicio"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Reinicio es obligatorio.<br />';";
			$errores = true;
		}
		elseif (!isFechaValida($_POST["fechaReinicio"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Reinicio debe ser una fecha válida.<br />';";
			$errores = true;
		}

		// Validación 6..
		if (dateDiff($_POST["fechaInicio"], $_POST["fechaReinicio"]) < 0) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Inicio debe ser menor o igual a la Fecha de Reinicio.<br />';";
			$errores = true;
		}

		// Validación 6.1..
		if ($_POST["fechaExtension"] == "") {
			if (dateDiff($_POST["fechaReinicio"], $_POST["fechaFinalizacion"]) < 0) {
				echo "errores+= '[DATOS GENERALES] - La Fecha de Fin debe ser mayor o igual a la Fecha de Reinicio.<br />';";
				$errores = true;
			}
		}
		else {
			if (dateDiff($_POST["fechaReinicio"], $_POST["fechaExtension"]) < 0) {
				echo "errores+= '[DATOS GENERALES] - La Fecha de Extensión debe ser mayor o igual a la Fecha de Reinicio.<br />';";
				$errores = true;
			}
		}

		// Validación 8..
		if (($_POST["fechaSuspensionEnabled"] == "t") and (dateDiff($_POST["fechaSuspension"], $_POST["fechaReinicio"]) < 0)) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Reinicio debe ser mayor a la Fecha de Suspensión.<br />';";
			$errores = true;
		}
	}

	// Validación 3..
	if (($_POST["fechaExtensionEnabled"] == "t") and ($_POST["tipoFormulario"] != "R") and ($_POST["origen"] != "r")) {
		if($_POST["fechaExtension"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Extensión es obligatorio.<br />';";
			$errores = true;
		}
		elseif (!isFechaValida($_POST["fechaExtension"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Fecha de Extensión debe ser una fecha válida.<br />';";
			$errores = true;
		}
	}

	if ($_POST["fechaExtensionEnabled"] == "t") {
		// Validación 6..
		if (dateDiff($_POST["fechaInicio"], $_POST["fechaExtension"]) < 0) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Inicio debe ser menor o igual a la Fecha de Extensión.<br />';";
			$errores = true;
		}

		// Validación 7..
		if (dateDiff($_POST["fechaFinalizacion"], $_POST["fechaExtension"]) < 0) {
			echo "errores+= '[DATOS GENERALES] - La Fecha de Extensión debe ser mayor a la Fecha de Finalización.<br />';";
			$errores = true;
		}
	}

	if ($_POST["caracteristicasObrador"] != "N") {
		// Validación 4..
		if ($_POST["superficieConstruir"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Superficie a Construir es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 4..
		if (!validarEntero($_POST["superficieConstruir"], true)) {
			echo "errores+= '[DATOS GENERALES] - El campo Superficie a Construir debe ser número entero.<br />';";
			$errores = true;
		}

		// Validación 4..
		if ($_POST["numeroPlantas"] == "") {
			echo "errores+= '[DATOS GENERALES] - El campo Número de Plantas es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 4..
		if (!validarEntero($_POST["numeroPlantas"])) {
			echo "errores+= '[DATOS GENERALES] - El campo Número de Plantas debe ser un número entero.<br />';";
			$errores = true;
		}
	}

	if ($_POST["caracteristicasObrador"] != "N") {
		// Validación 5..
		if ((!isset($_POST["caminos"])) and (!isset($_POST["tuneles"])) and (!isset($_POST["puertos"])) and (!isset($_POST["calles"])) and (!isset($_POST["obrasFerroviarias"])) and
				(!isset($_POST["aeropuertos"])) and (!isset($_POST["autopistas"])) and (!isset($_POST["obrasHidraulicas"])) and (!isset($_POST["otras"])) and (!isset($_POST["puentes"]))and
				(!isset($_POST["tratamientoAgua"])) and (!isset($_POST["viviendasUnifamiliares"])) and (!isset($_POST["edificiosOficina"])) and (!isset($_POST["edificiosPisosMultiples"])) and
				(!isset($_POST["escuelas"])) and (!isset($_POST["obrasUrbanizacion"])) and (!isset($_POST["hospitales"])) and (!isset($_POST["edificiosComerciales"])) and
				(!isset($_POST["otrasEdific"])) and (!isset($_POST["destileria"])) and (!isset($_POST["generacionElectrica"])) and (!isset($_POST["obrasMineria"])) and
				(!isset($_POST["industriaManufactureraUrbana"])) and (!isset($_POST["demasMontajesIndustriales"])) and (!isset($_POST["tuberias"])) and (!isset($_POST["estaciones"])) and
				(!isset($_POST["ductosOtras"])) and (!isset($_POST["transElectricaAltoVoltaje"])) and (!isset($_POST["transElectricaBajoVoltaje"])) and (!isset($_POST["comunicaciones"])) and
				(!isset($_POST["otrasObrasRedes"])) and (!isset($_POST["excavacionesSubterraneas"])) and (!isset($_POST["instalacionesHidraulicas"])) and
				(!isset($_POST["instalacionesElectromecanicas"])) and (!isset($_POST["instalacionesAireAcondicionado"])) and (!isset($_POST["reparaciones"])) and (!isset($_POST["otrasObras"]))) {
			echo "errores+= '- Debe seleccionar algún item de los grupos INGENIERÍA CIVIL, ARQUITECTURA, MONTAJE INDUSTRIAL, DUCTOS, REDES u OTRAS CONSTRUCCIONES.<br />';";
			$errores = true;
		}


		if (($_POST["fechaDesdeExcavacion"] != "") and (!isFechaValida($_POST["fechaDesdeExcavacion"]))) {
			echo "errores+= '[ACTIVIDAD] - El campo Excavación Fecha Desde debe ser una fecha válida.<br />';";
			$errores = true;
		}

		if (($_POST["fechaHastaExcavacion"] != "") and (!isFechaValida($_POST["fechaHastaExcavacion"]))) {
			echo "errores+= '[ACTIVIDAD] - El campo Excavación Fecha Hasta debe ser una fecha válida.<br />';";
			$errores = true;
		}

		if (($_POST["fechaDesdeDemolicion"] != "") and (!isFechaValida($_POST["fechaDesdeDemolicion"]))) {
			echo "errores+= '[ACTIVIDAD] - El campo Demolición Fecha Desde debe ser una fecha válida.<br />';";
			$errores = true;
		}

		if (($_POST["fechaHastaDemolicion"] != "") and (!isFechaValida($_POST["fechaHastaDemolicion"]))) {
			echo "errores+= '[ACTIVIDAD] - El campo Demolición Fecha Hasta debe ser una fecha válida.<br />';";
			$errores = true;
		}
		
		// Validación 10..
		if (isset($_POST["excavacion"])) {
			if ($_POST["fechaDesdeExcavacion"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Excavación Fecha Desde es obligatorio.<br />';";
				$errores = true;
			}

			if ($_POST["fechaHastaExcavacion"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Excavación Fecha Hasta es obligatorio.<br />';";
				$errores = true;
			}
			
			if (!isset($_POST["submuraciones"]) and !isset($_POST["subsuelos"])) {
				echo "errores+= '[ACTIVIDAD] - El campo submuración o subsuelo debe estar seleccionado, si esta seleccionado excavación.<br />';";
				$errores = true;
			}
			
			
			if (dateDiff($_POST["fechaDesdeExcavacion"], $_POST["fechaHastaExcavacion"]) < 0) {
				echo "errores+= '[ACTIVIDAD] - La Fecha Desde Excavación debe ser menor a la Fecha Hasta Excavación.<br />';";
				$errores = true;
			}

			// Validación 11..
			if (dateDiff($_POST["fechaInicio"], $_POST["fechaDesdeExcavacion"]) < 0) {
				echo "errores+= '[ACTIVIDAD] - La Fecha Desde Excavación debe ser mayor o igual a la Fecha de Inicio.<br />';";
				$errores = true;
			}

			// Validación 12..
			if ($_POST["fechaExtension"] != "") {
				if (dateDiff($_POST["fechaExtension"], $_POST["fechaDesdeExcavacion"]) < 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Desde Excavación debe ser menor o igual a la Fecha de Extensión.<br />';";
					$errores = true;
				}
			}
			else {
				if (dateDiff($_POST["fechaFinalizacion"], $_POST["fechaDesdeExcavacion"]) > 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Desde Excavación debe ser menor o igual a la Fecha de Finalización.<br />';";
					$errores = true;
				}
			}

			// Validación 13..
			if ($_POST["fechaExtension"] != "") {
				if (dateDiff($_POST["fechaExtension"], $_POST["fechaHastaExcavacion"]) < 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Hasta Excavación debe ser menor o igual a la Fecha de Extensión.<br />';";
					$errores = true;
				}
			}
			else {
				if (dateDiff($_POST["fechaFinalizacion"], $_POST["fechaHastaExcavacion"]) > 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Hasta Excavación debe ser menor o igual a la Fecha de Finalización.<br />';";
					$errores = true;
				}
			}
		}

		// Validación 14..
		if (isset($_POST["demolicion"])) {
			if ($_POST["fechaDesdeDemolicion"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Demolición Fecha Desde es obligatorio.<br />';";
				$errores = true;
			}

			if ($_POST["fechaHastaDemolicion"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Demolición Fecha Hasta es obligatorio.<br />';";
				$errores = true;
			}

			if (dateDiff($_POST["fechaDesdeDemolicion"], $_POST["fechaHastaDemolicion"]) < 0) {
				echo "errores+= '[ACTIVIDAD] - La Fecha Desde Demolición debe ser menor a la Fecha Hasta Demolición.<br />';";
				$errores = true;
			}
			
			if (!isset($_POST["total"]) and !isset($_POST["parcial"])) {
				echo "errores+= '[ACTIVIDAD] - El campo total o parcial debe estar seleccionado, si esta seleccionado demolición.<br />';";
				$errores = true;
			}

			// Validación 15..
			if (dateDiff($_POST["fechaInicio"], $_POST["fechaDesdeDemolicion"]) < 0) {
				echo "errores+= '[ACTIVIDAD] - La Fecha Desde Demolición debe ser mayor o igual a la Fecha de Inicio.<br />';";
				$errores = true;
			}

			// Validación 16..
			if ($_POST["fechaExtension"] != "") {
				if (dateDiff($_POST["fechaExtension"], $_POST["fechaDesdeDemolicion"]) < 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Desde Demolición debe ser menor o igual a la Fecha de Extensión.<br />';";
					$errores = true;
				}
			}
			else {
				if (dateDiff($_POST["fechaFinalizacion"], $_POST["fechaDesdeDemolicion"]) > 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Desde Demolición debe ser menor o igual a la Fecha de Finalización.<br />';";
					$errores = true;
				}
			}

			// Validación 17..
			if ($_POST["fechaExtension"] != "") {
				if (dateDiff($_POST["fechaExtension"], $_POST["fechaHastaDemolicion"]) < 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Hasta Demolición debe ser menor o igual a la Fecha de Extensión.<br />';";
					$errores = true;
				}
			}
			else {
				if (dateDiff($_POST["fechaFinalizacion"], $_POST["fechaHastaDemolicion"]) > 0) {
					echo "errores+= '[ACTIVIDAD] - La Fecha Hasta Demolición debe ser menor o igual a la Fecha de Finalización.<br />';";
					$errores = true;
				}
			}
		}

		// Validación 17.1..
		if (isset($_POST["excavacion503"])) {
			if ($_POST["fechaDesdeExcavacion503"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Fecha Desde de Otras Excavaciones es obligatorio.<br />';";
				$errores = true;
			}
			if ($_POST["fechaHastaExcavacion503"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Fecha Hasta de Otras Excavaciones es obligatorio.<br />';";
				$errores = true;
			}
			if (dateDiff($_POST["fechaDesdeExcavacion503"], $_POST["fechaHastaExcavacion503"]) < 0) {
				echo "errores+= '[ACTIVIDAD] - El campo Fecha Hasta de Otras Excavaciones debe ser posterior al campo Fecha Desde de Otras Excavaciones.<br />';";
				$errores = true;
			}
			if ($_POST["detallarExcavacion503"] == "") {
				echo "errores+= '[ACTIVIDAD] - El campo Detallar de Otras Excavaciones es obligatorio.<br />';";
				$errores = true;
			}
		}


		// Validación 18..
		if (isset($_POST["comitente"])) {
			if (($_POST["cuitComitente"] == "") and ($_POST["razonSocialComitente"] == "")) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - Debe ingresar la C.U.I.T. o la Razón Social del Comitente.<br />';";
				$errores = true;
			}

			if (($_POST["cuitComitente"] != "") and (!validarCuit($_POST["cuitComitente"]))) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - La C.U.I.T. del Comitente es inválida.<br />';";
				$errores = true;
			}
		}

		// Validación 19..
		if (isset($_POST["contratistaPrincipal"])) {
			if (($_POST["cuitContratistaPrincipal"] == "") and ($_POST["razonSocialContratistaPrincipal"] == "")) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - Debe ingresar la C.U.I.T. o la Razón Social del Contratista Principal.<br />';";
				$errores = true;
			}

			if (($_POST["cuitContratistaPrincipal"] != "") and (!validarCuit($_POST["cuitContratistaPrincipal"]))) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - La C.U.I.T. del Contratista Principal es inválida.<br />';";
				$errores = true;
			}
		}

		// Validación 20..
		if (isset($_POST["subcontratista"])) {
			if (($_POST["cuitSubcontratista"] == "") and ($_POST["razonSocialSubcontratista"] == "")) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - Debe ingresar la C.U.I.T. o la Razón Social del Subcontratista.<br />';";
				$errores = true;
			}

			if (($_POST["cuitSubcontratista"] != "") and (!validarCuit($_POST["cuitSubcontratista"]))) {
				echo "errores+= '[COMITENTE - CONTRATISTA] - La C.U.I.T. del Subcontratista es inválida.<br />';";
				$errores = true;
			}
		}

		// Validación 21..
		if ($_POST["tipoDocumentoHYS"] == -1) {
			echo "errores+= '[RESPONSABLE HYS] - El campo Tipo Documento es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 21..
		if ($_POST["numeroDocumentoHYS"] == "") {
			echo "errores+= '[RESPONSABLE HYS] - El campo Nº Documento es obligatorio.<br />';";
			$errores = true;
		}
		else if (($_POST["tipoDocumentoHYS"] == "CUIL") and (!validarCuit($_POST["numeroDocumentoHYS"]))) {
			echo "errores+= '[RESPONSABLE HYS] - El campo Nº Documento no es una C.U.I.L. válida.<br />';";
			$errores = true;
		}
		else if (($_POST["tipoDocumentoHYS"] == "CUIT") and (!validarCuit($_POST["numeroDocumentoHYS"]))) {
			echo "errores+= '[RESPONSABLE HYS] - El campo Nº Documento no es una C.U.I.T. válida.<br />';";
			$errores = true;
		}

		// Validación 21..
		if ($_POST["sexoHYS"] == -1) {
			echo "errores+= '[RESPONSABLE HYS] - El campo Sexo es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 21..
		if ($_POST["nombreApellidoHYS"] == "") {
			echo "errores+= '[RESPONSABLE HYS] - El campo Nombre y Apellido es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 21..
		if ($_POST["cargoHYS"] == -1) {
			echo "errores+= '[RESPONSABLE HYS] - El campo Cargo es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 21..
		if ($_POST["emailHYS"] == "") {
			echo "errores+= '[RESPONSABLE HYS] - El campo e-Mail es obligatorio.<br />';";
			$errores = true;
		}
		else {
			$params = array(":email" => $_POST["emailHYS"]);
			$sql = "SELECT art.varios.is_validaemail(:email) FROM DUAL";
			if (ValorSql($sql, "", $params) != "S") {
				echo "errores+= '[RESPONSABLE HYS] - El e-Mail cargado debe ser válido.<br />';";
				$errores = true;
			}
		}

		// Validación 21..
		if ($_POST["telefonosCargados"] != "t") {
			echo "errores+= '[RESPONSABLE HYS] - Debe tener cargado al menos un teléfono.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["tipoDocumento"] == -1) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Tipo Documento es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["numeroDocumento"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Nº Documento es obligatorio.<br />';";
			$errores = true;
		}
		else if (($_POST["tipoDocumento"] == "CUIL") and (!validarCuit($_POST["numeroDocumento"]))) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Nº Documento no es una C.U.I.L. válida.<br />';";
			$errores = true;
		}
		else if (($_POST["tipoDocumento"] == "CUIT") and (!validarCuit($_POST["numeroDocumento"]))) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Nº Documento no es una C.U.I.T. válida.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["sexo"] == -1) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Sexo es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["nombre"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Nombre es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["apellido"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Apellido es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["codigoArea"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Código Área es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["telefono"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Teléfono es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if (!tieneSoloNumeros($_POST["telefono"])) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Teléfono solo puede contener caracteres numéricos.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["tipoTelefono"] == -1) {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo Tipo Teléfono es obligatorio.<br />';";
			$errores = true;
		}

		// Validación 22..
		if ($_POST["email"] == "") {
			echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El campo e-Mail es obligatorio.<br />';";
			$errores = true;
		}
		else {
			$params = array(":email" => $_POST["email"]);
			$sql = "SELECT art.varios.is_validaemail(:email) FROM DUAL";
			if (valorSql($sql, "", $params) != "S") {
				echo "errores+= '[RESPONSABLE DE LOS DATOS DECLARADOS EN EL FORMULARIO] - El e-Mail cargado debe ser válido.<br />';";
				$errores = true;
			}
		}
	}

	if ($errores) {
		echo "getElementById('imgProcesando').style.display = 'none';";
		echo "getElementById('btnGuardar').style.display = 'inline';";
		echo "getElementById('errores').innerHTML = errores;";
		echo "getElementById('divErrores').style.display = 'inline';";
		echo "getElementById('foco').style.display = 'block';";

		echo "getElementById('foco').focus();";
		echo "getElementById('foco').style.display = 'none';";
	}
	else {
		echo "getElementById('divErrores').style.display = 'none';";
	}

	echo "}";
	echo "</script>";

	return !$errores;
}
Example #9
0
					$existeValor = true;
					
			if (!$existeValor){	break;}
			else { $CountRegInsert++; }
						
			$errores = "";
			$cuilTrabajador = $cols["A"];
			$fechaIng = true;
			$fechaExpo = true;
			$cuilValido = true;			
			
			if ( strlen(trim($cols["A"])) != 11 ){
					$errores .= "* Cuil Incompleto ";
					$cuilValido = false;
			}else{
				if (!validarCuit(trim($cols["A"]))){
					$errores .= "* Cuil Invalido ";
					$cuilValido = false;	
				}
			}
				
			if( !ValidaSoloNumerosRExp( trim($cols["A"]) ) )
				$errores .= "* Cuil Contiene caracteres invalidos ";
				
			if ($cols["B"] == "")
				$errores .= "* Apellido nombre vacio ";
			
			if ( !ValidaSoloLetrasEspRExp($cols["B"]) )
				$errores .= "* Apellido Nombre contiene caracteres invalidos ";

			try {
	public function validateSolicitud($datosSolicitud) {
		global $conn;

		$this->datosSolicitud = $datosSolicitud;

		$advertencias = "";
		$errores = "";

		try {
			$this->completeData();
			$this->insertEstablecimientos();

			// Validación 1..
			if (!validarCuit($datosSolicitud["cuit"])) {
				$errores.= "<error><codigo>1</codigo>";
				$errores.= "<mensaje>La C.U.I.T. es inválida.</mensaje></error>";
				throw new Exception("ERROR FATAL: La C.U.I.T. es inválida.");		// Este error lo lanzo porque con una CUIT inválida no puedo ni validar nada..
			}

			// Validación 2 - Control de CUIT reservado..
			$params = array(":cuit" => $datosSolicitud["cuit"]);
			$sql =
				"SELECT ac_descripcion actividad, ca_descripcion canal, en_nombre entidad, ru_idcanal, ru_identidad, ru_idvendedor, ru_observaciones, ve_nombre vendedor
					 FROM aru_reservacuit ru, aca_canal, cac_actividad, xen_entidad, xve_vendedor
					WHERE ru_idcanal = ca_id(+)
						AND ru_idactividad = ac_id(+)
						AND ru_identidad = en_id(+)
						AND ru_idvendedor = ve_id(+)
						AND ru_cuit = :cuit
						AND ru_fechabaja IS NULL
						AND actualdate BETWEEN ru_fechadesde AND ru_fechahasta";
			$stmt = DBExecSql($conn, $sql, $params);
			if (DBGetRecordCount($stmt) > 0) {
				$row = DBGetQuery($stmt);

				$distintoVendedor = (($row["VENDEDOR"] != "") and ($row["RU_IDVENDEDOR"] != $this->datosUsuario["VENDEDOR"]));
				if (($row["RU_IDCANAL"] != $this->datosUsuario["CANAL"]) or ($row["RU_IDENTIDAD"] != $this->datosUsuario["ENTIDAD"]) or ($distintoVendedor)) {
					$errores.= "<error><codigo>2</codigo>";
					$errores.= "<mensaje>Esta C.U.I.T. se encuentra reservada por otro usuario, por favor comuníquese con su Ejecutivo de Provincia ART.</mensaje>";
					$errores.= "<observaciones>".$row["RU_OBSERVACIONES"]."</observaciones></error>";
				}
			}

			// Validación 3 - Control de vigencia de la Solicitud de Cotización..
			$params = array(":cuit" => $datosSolicitud["cuit"]);
			$sql =
				"SELECT ca_descripcion
					 FROM asc_solicitudcotizacion, aca_canal
					WHERE ca_id = sc_canal
						AND (actualdate - TRUNC(sc_fechasolicitud)) < 30
						AND sc_estado NOT IN('05', '07', '08', '09', '18.0', '18.1', '18.2', '18.3')
						AND sc_cuit = :cuit";
			$stmt = DBExecSql($conn, $sql, $params);
			if (DBGetRecordCount($stmt) > 0) {
				$errores.= "<error><codigo>3</codigo>";
				$errores.= "<mensaje>Ya existe una solicitud para esta C.U.I.T., por favor comuníquese con su Ejecutivo de Provincia ART.</mensaje></error>";
			}

			// Validación 4 - Control de vigencia de la Revision de Precio..
			$params = array(":cuit" => $datosSolicitud["cuit"]);
			$sql =
				"SELECT ca_descripcion
					 FROM art.asr_solicitudreafiliacion 
					 JOIN aca_canal ON ca_id = sr_idcanal
					WHERE (art.actualdate - TRUNC(sr_fechaalta)) < 30
						AND sr_estadosolicitud NOT IN('05', '18.0', '18.1', '18.2', '18.3')
						AND sr_cuit = :cuit";
			$stmt = DBExecSql($conn, $sql, $params);
			if (DBGetRecordCount($stmt) > 0) {
				$errores.= "<error><codigo>4</codigo>";
				$errores.= "<mensaje>Ya existe una solicitud para esta C.U.I.T., por favor comuníquese con su Ejecutivo de Provincia ART.</mensaje></error>";
			}

			// Validación 5..
			$params = array(":cuit" => $datosSolicitud["cuit"]);
			$sql = "SELECT afiliacion.check_cobertura(:cuit) FROM DUAL";
			if (ValorSql($sql, "", $params) == 1) {
				$errores.= "<error><codigo>5</codigo>";
				$errores.= "<mensaje>Esta empresa ya tiene un contrato activo con esta aseguradora.</mensaje></error>";
			}

			// Validación 6 - Que no puedan colocar la CUIT de la Provincia ART..
			if ($datosSolicitud["cuit"] == "30688254090") {
				$errores.= "<error><codigo>6</codigo>";
				$errores.= "<mensaje>Debe registrarse la C.U.I.T. del empleador (si la C.U.I.T. se registra erróneamente la solicitud no tiene validez).</mensaje></error>";
			}

			// Validación 7 - Valida el status ante la SRT..
			$params = array(":cuit" => $datosSolicitud["cuit"]);
			$sql =
				"SELECT 1
					 FROM srt.sem_empresas e JOIN srt.shv_historialvigencias v ON v.hv_id = art.cotizacion.get_idultimavigencia(em_cuit)
					WHERE CASE
								WHEN v.hv_idoperaciondesde = 10888 THEN ADD_MONTHS(v.hv_vigenciadesde, 10) + 11
								ELSE ADD_MONTHS(v.hv_vigenciadesde, 6)
								END <= SYSDATE
						AND e.em_cuit = :cuit";
			if (($this->datosSolicitud["statusSrtAutomatico"]->getStatus() != -1) and ($this->datosSolicitud["statusSrtAutomatico"]->getStatus() != 1) and (!ExisteSql($sql, $params, 0))) {
				$errores.= "<error><codigo>7</codigo>";
				$errores.= "<mensaje>Esta C.U.I.T. no puede ser cotizada por la vigencia en la actual ART, por favor comuníquese con su Ejecutivo de Provincia ART.</mensaje></error>";
			}

			// Validación 8..
			if ($datosSolicitud["statusSrt"] < 1) {
				$errores.= "<error><codigo>8</codigo>";
				$errores.= "<mensaje>El status ante la SRT debe ser mayor a cero (0).</mensaje></error>";
			}

			// Validación 9..
			$codigoVendedor = NULL;
			if (($this->datosUsuario["ENTIDAD"] == 9003) and ($this->datosUsuario["VENDEDOR"] == "")) {
				if ($this->datosSolicitud["codigoVendedor"] == NULL) {
					$errores.= "<error><codigo>9</codigo>";
					$errores.= "<mensaje>El código de vendedor es inválido.</mensaje></error>";
				}
			}

			// Validación 10..
			if ($this->datosSolicitud["totalTrabajadores"] == 0) {
				$errores.= "<error><codigo>10</codigo>";
				$errores.= "<mensaje>El total de trabajadores debe ser mayor a cero (0).</mensaje></error>";
			}

			// Validación 11..
			if ($this->datosSolicitud["totalMasaSalarial"] == 0) {
				$errores.= "<error><codigo>11</codigo>";
				$errores.= "<mensaje>El total de la masa salarial debe ser mayor a cero (0).</mensaje></error>";
			}

			// Validación 12..
			if (!$this->validatePeriodo()) {
				$errores.= "<error><codigo>12</codigo>";
				$errores.= "<mensaje>El período es inválido, el formato debe ser AAAA/MM.</mensaje></error>";
			}

			$this->SPValidation($advertencias, $errores);
		}
		catch (Exception $e) {
//			$errores.= "<error>".$e->getMessage()."</error>";
			$errores.= "<error><fecha>".date("d/m/Y")."</fecha><hora>".date("H:i:s")."</hora><mensaje>Ocurrió un error inesperado en la función validarSolicitud.</mensaje></error>";
		}

		if (($advertencias == "") and ($errores == ""))
			return "";
		else {
			$xml = '<?xml version="1.0" encoding="utf-8"?><solicitudCotizacion>';
			if ($advertencias != "")
				$xml.= "<advertencias>".$advertencias."</advertencias>";
			if ($errores != "")
				$xml.= "<errores>".$errores."</errores>";
			$xml.= "</solicitudCotizacion>";
			return new soapval("return", "xsd:string", $xml);
		}
	}
Example #11
0
session_start();

require_once($_SERVER["DOCUMENT_ROOT"]."/constants.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/../Common/database/db.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/../Common/miscellaneous/cuit.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/../Common/miscellaneous/numbers_utils.php");
require_once($_SERVER["DOCUMENT_ROOT"]."/functions/general.php");


validarSesion(isset($_SESSION["isCliente"]));
validarSesion((isset($_SESSION["isAdminTotal"])) and ($_SESSION["isAdminTotal"]));


$cuit = sacarGuiones($_REQUEST["valor"]);

if (validarCuit($cuit)) {
	$msg = " Esta C.U.I.T. no puede ser capturada. ";
	$params = array(":cuit" => $cuit);
	$sql = " AND em_cuit = :cuit";
}
elseif (validarEntero($_REQUEST["valor"])) {
	$msg = " Este contrato no puede ser capturado. ";
	$params = array(":contrato" => $_REQUEST["valor"]);
	$sql = " AND co_contrato = :contrato";
}
else {
	$msg = " Esta empresa no puede ser capturada. ";
	$params = array(":nombre" => $_REQUEST["valor"]."%");
	$sql = " AND em_nombre LIKE UPPER(:nombre)";
}
function validar() {
	$errores = false;

	echo '<script src="/modules/usuarios_registrados/clientes/js/denuncia_siniestros.js" type="text/javascript"></script>';
	echo "<script type='text/javascript'>";
	echo "with (window.parent.document) {";
	echo "var errores = '';";

	if ($_POST["idTrabajador"] == -1) {
		echo "paso = 1;";
		echo "errores+= '- Apellido y Nombre vacío.<br />';";
		$errores = true;
	}

	if (!isFechaValida($_POST["fechaNacimiento"], false)) {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Fecha Nacimiento vacía o errónea.<br />';";
		$errores = true;
	}
	else {
		$edad = dateDiff($_POST["fechaNacimiento"], date("d/m/Y"), "A");
		if (($edad <= 16) or ($edad >= 90)) {
			if (!$errores)
				echo "paso = 1;";
			echo "errores+= '- La edad del trabajador debe estar entre 16 y 90 años.<br />';";
			$errores = true;
		}
	}

	if ($_POST["fechaIngreso"] != "")
		if (!isFechaValida($_POST["fechaIngreso"])) {
			if (!$errores)
				echo "paso = 1;";
			echo "errores+= '- Fecha Ingreso a la Empresa errónea.<br />';";
			$errores = true;
		}

	if ($_POST["idProvincia"] == -1) {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Domicilio vacío.<br />';";
		$errores = true;
	}

	if ($_POST["telefono"] == "") {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Teléfono vacío.<br />';";
		$errores = true;
	}

	if ($_POST["numero"] == "") {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Número de calle del domicilio vacío.<br />';";
		$errores = true;
	}

	if ($_POST["puesto"] == "") {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Puesto vacío.<br />';";
		$errores = true;
	}

	if (($_POST["horaDesde"] == "-1") or ($_POST["minutoDesde"] == "-1") or ($_POST["horaHasta"] == "-1") and ($_POST["minutoHasta"] == "-1")) {
		if (!$errores)
			echo "paso = 1;";
		echo "errores+= '- Horario habitual de Trabajo vacío.<br />';";
		$errores = true;
	}

	if ($_POST["tipoSiniestro"] == -1) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Tipo de Siniestro vacío.<br />';";
		$errores = true;
	}

	if (!isFechaValida($_POST["fechaSiniestro"])) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Fecha Siniestro vacía o inválida.<br />';";
		$errores = true;
	}
	elseif (!fechaEnRango($_POST["fechaSiniestro"], "01/07/1996", date("d/m/Y"))) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- La Fecha del Siniestro no puede ser posterior al día de hoy.<br />';";
		$errores = true;
	}

	if ($_POST["fechaRecaida"] != "") {
		if (!isFechaValida($_POST["fechaRecaida"])) {
			if (!$errores)
				echo "paso = 2;";
			echo "errores+= '- Fecha de Recaída inválida.<br />';";
			$errores = true;
		}
		elseif (!fechaEnRango($_POST["fechaRecaida"], "01/07/1996", date("d/m/Y"))) {
			if (!$errores)
				echo "paso = 2;";
			echo "errores+= '- La Fecha del Recaída no puede ser posterior al día de hoy.<br />';";
			$errores = true;
		}
	}

	if (($_POST["lugarOcurrencia"] == 1) and ($_POST["establecimientoPropio"] == -1) and (((isset($_POST["establecimientoTercero"])) and ($_POST["establecimientoTercero"] == -1)) or (!isset($_POST["establecimientoTercero"])))) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Debe seleccionar el Establecimiento Propio.<br />';";
		$errores = true;
	}

/*	if ($_POST["idProvinciaAccidente"] == -1) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Domicilio de ocurrencia del accidente vacío.<br />';";
		$errores = true;
	}*/
	if ($_POST["calleAccidente"] == "") {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Calle de ocurrencia del accidente vacío.<br />';";
		$errores = true;
	}

	if ($_POST["numeroAccidente"] == "") {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Número de calle del domicilio de ocurrencia del accidente vacío.<br />';";
		$errores = true;
	}

	if ($_POST["codigoPostalAccidente"] == -1) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Provincia de ocurrencia del accidente vacío.<br />';";
		$errores = true;
	}

	if ($_POST["provinciaAccidente"] == -1) {
		if (!$errores)
			echo "paso = 2;";
		echo "errores+= '- Provincia de ocurrencia del accidente vacío.<br />';";
		$errores = true;
	}

	if ($_POST["establecimientoAccidente"] == 0)
		if ($_POST["cuitContratista"] == "") {
			if (!$errores)
				echo "paso = 2;";
			echo "errores+= '- C.U.I.T. Contratista vacío.<br />';";
			$errores = true;
		}

	if ($_POST["cuitContratista"] != "")
		if (!validarCuit($_POST["cuitContratista"])) {
			if (!$errores)
				echo "paso = 2;";
			echo "errores+= '- C.U.I.T. Contratista inválido.<br />';";
			$errores = true;
		}



	if ($_POST["descripcionHecho"] == "") {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Descripción del Hecho vacío.<br />';";
		$errores = true;
	}

	if ($_POST["formaAccidente"] == -1) {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Forma del Accidente vacío.<br />';";
		$errores = true;
	}

	if ($_POST["agenteMaterial"] == -1) {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Agente Material vacío.<br />';";
		$errores = true;
	}

	if ($_POST["parteCuerpoLesionada"] == -1) {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Parte del Cuerpo Lesionada vacío.<br />';";
		$errores = true;
	}

	if ($_POST["naturalezaLesion"] == -1) {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Naturaleza de la Lesión vacía.<br />';";
		$errores = true;
	}

	if ($_POST["gravedadPresunta"] == -1) {
		if (!$errores)
			echo "paso = 3;";
		echo "errores+= '- Gravedad Presunta vacía.<br />';";
		$errores = true;
	}

	if ($_POST["dni"] != "")
		if (!validarEntero($_POST["dni"])) {
			if (!$errores)
				echo "paso = 5;";
			echo "errores+= '- El D.N.I. del Denunciante es inválido.<br />';";
			$errores = true;
		}


	if ($errores) {
		echo "window.parent.paso = paso;";
		echo "window.parent.cambiarPaso(paso);";
		echo "getElementById('imgProcesando').style.display = 'none';";
		echo "getElementById('errores').innerHTML = errores;";
		echo "getElementById('divErrores').style.display = 'inline';";
		echo "getElementById('foco').style.display = 'block';";
		echo "getElementById('foco').focus();";
		echo "getElementById('foco').style.display = 'none';";
	}
	else {
		echo "getElementById('divErrores').style.display = 'none';";
	}

	echo "}";
	echo "</script>";

	return !$errores;
}
Example #13
0
function validar() {
	$errores = false;

	echo "<script type='text/javascript'>";
	echo "with (window.parent.document) {";
	echo "var errores = '';";


	if (($_POST["fechaNacimiento"] != "") and (!isFechaValida($_POST["fechaNacimiento"]))) {
		echo "errores+= '- El campo Fecha Nacimiento debe ser una fecha válida.<br />';";
		$errores = true;
	}

	if (($_POST["piso"] != "") and (!validarEntero($_POST["piso"]))) {
		echo "errores+= '- El campo Piso debe ser un entero válido.<br />';";
		$errores = true;
	}

	if (($_POST["codigoInternoRRHH"] != "") and (!validarEntero($_POST["codigoInternoRRHH"]))) {
		echo "errores+= '- El campo Código Interno RRHH debe ser un entero válido.<br />';";
		$errores = true;
	}

	if ($_POST["legajoRRHH"] == "") {
		echo "errores+= '- El campo Legajo RRHH es obligatorio.<br />';";
		$errores = true;
	}
	elseif (!validarEntero($_POST["legajoRRHH"])) {
		echo "errores+= '- El campo Legajo RRHH debe ser un entero válido.<br />';";
		$errores = true;
	}

	if (($_POST["cuil"] != "") and (!validarCuit($_POST["cuil"]))) {
		echo "errores+= '- El campo C.U.I.L. debe ser una C.U.I.L. válida.<br />';";
		$errores = true;
	}

	if ($_POST["id"] == $_POST["respondeA"]) {
		echo "errores+= '- El usuario no puede responder a si mismo.<br />';";
		$errores = true;
	}

	if (($_POST["relacionLaboral"] == 1) and ($_POST["legajoRRHH"] != 0)) {
		$params = array(":id" => $_POST["id"], ":legajorrhh" => $_POST["legajoRRHH"]);
		$sql =
			"SELECT 1
				 FROM use_usuarios
				WHERE se_legajorrhh = :legajorrhh
					AND se_id <> :id";
		if (existeSql($sql, $params, 0)) {		// Valido que no exista el Nº de Legajo..
			echo "errores+= '- El Legajo RRHH ya fue asignado a otro usuario.<br />';";
			$errores = true;
		}
	}


	if ($errores) {
		echo "body.style.cursor = 'default';";
		echo "getElementById('btnGuardar').style.display = 'inline';";
		echo "getElementById('imgProcesando').style.display = 'none';";
		echo "getElementById('errores').innerHTML = errores;";
		echo "getElementById('divErroresForm').style.display = 'block';";
		echo "getElementById('foco').style.display = 'block';";
		echo "getElementById('foco').focus();";
		echo "getElementById('foco').style.display = 'none';";
	}
	else {
		echo "getElementById('divErroresForm').style.display = 'none';";
	}

	echo "}";
	echo "</script>";

	return !$errores;
}