Files
ads-faltas-2025/Example/Telas/altCliente.php

284 lines
15 KiB
PHP

<?php
//include '../Includes/valida_sessao.inc';
require_once("../Controle/ControleCliente.php");
$objCliente = new Cliente;
$objCliente = $objCliente->buscarPorId($_POST['codCliente']);
/*require_once ("../Controle/ControleEstado.php");
$objEstado = new Estado;
$objEstados = $objEstado->buscarTodos();
$contadorEstado = count($objEstados);
require_once ("../Controle/ControleCidade.php");
$objCidade = new Cidade;
$objCidades = $objCidade->buscarTodos();
$contadorCidade = count($objCidades);
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8">
<link rel="stylesheet" type="text/css" href="../CSS/estilo.css" media="screen" />
<title>Alteração de Cliente</title>
<script language="JavaScript" type="text/javascript" src="../Js/ajaxInit.js"></script>
<script src="../AJAX/BibliotecaAJAX.js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
$('input').keypress(function(e) {
var code = null;
code = (e.keyCode ? e.keyCode : e.which);
return (code == 13) ? false : true;
});
});
function voltar(){
location.href = 'listCliente.php';
}
function mascaraTel(telefone){
if(telefone.value.length == '0'){
document.form.telefone.value = '(' + telefone.value;
}
if(telefone.value.length == '3'){
document.form.telefone.value = telefone.value + ') ';
}
if(telefone.value.length == '9'){
document.form.telefone.value = telefone.value + '-';
}
}
function mascaraCel(celular){
if(celular.value.length == '0'){
document.form.celular.value = '(' + celular.value;
}
if(celular.value.length == '3'){
document.form.celular.value = celular.value + ') ';
}
if(celular.value.length == '9'){
document.form.celular.value = celular.value + '-';
}
}
function mascaraCPF(cpf){
if(cpf.value.length == '3'){
document.form.cpf.value = cpf.value + '.';
}
if(cpf.value.length == '7'){
document.form.cpf.value = cpf.value + '.';
}
if(cpf.value.length == '11'){
document.form.cpf.value = cpf.value + '-';
}
}
function mascaraCEP(cep){
if(cep.value.length == '2'){
document.form.cep.value = cep.value + '.';
}
if(cep.value.length == '6'){
document.form.cep.value = cep.value + '-';
}
}
function mascaraData(datNascimento){
if(datNascimento.value.length == '2'){
document.form.datNascimento.value = datNascimento.value + '/';
}
if(datNascimento.value.length == '5'){
document.form.datNascimento.value = datNascimento.value + '/';
}
}
//AJAX DAS CIDADES
function selecionaCidade() {
// //alert("alterou estado");
objHTTPRequest = ajaxInit();
if(objHTTPRequest){
// //alert("criou httprequest");
document.getElementById("caixaCidade").innerHTML = "<select name=\"cidade\" id=\"cidade\" disabled=\"disabled\"><option value=\"Todos\" selected=\"selected\">Carregando...</option></select>";
var estado = document.getElementById("estado").value;
var cidade = encodeURI("<?php echo $objCliente->get('cidade'); ?>");
objHTTPRequest.onreadystatechange = escreveCidades;
var url = "../Js/CidadesAjax.php?estado=" + estado + "&cidade=" + cidade;
// //alert(url);
objHTTPRequest.open('GET', url, true);
objHTTPRequest.send(null);
}
}
function escreveCidades() {
if(objHTTPRequest.readyState == 0) {
document.getElementById("carregando").innerHTML = "<img src=\"../Imagens/spinner_small.gif\" />";
}
if(objHTTPRequest.readyState == 1) {
document.getElementById("carregando").innerHTML = "<img src=\"../Imagens/spinner_small.gif\" />";
}
if(objHTTPRequest.readyState == 2) {
document.getElementById("carregando").innerHTML = "<img src=\"../Imagens/spinner_small.gif\" />";
}
if(objHTTPRequest.readyState == 3) {
document.getElementById("carregando").innerHTML = "<img src=\"../Imagens/spinner_small.gif\" />";
}
if(objHTTPRequest.readyState == 4) {
if (objHTTPRequest.status == 200) {
document.getElementById("caixaCidade").innerHTML = objHTTPRequest.responseText;
document.getElementById("carregando").innerHTML = "";
}
}
}
function contOBS(qtCaracteres){
if (qtCaracteres > 1000){
document.getElementById("contOBS").innerHTML = (1000 - qtCaracteres) * (-1) + " caracteres excedidos";
}else{
document.getElementById("contOBS").innerHTML = 1000 - qtCaracteres + " caracteres restantes";
}
}
function buscaAJAX(busca, idResultado){
////busca é o atributo informado para buscaAJAX.php
//idResultado é o id do elemento que receberá a resposta.
$('#' + idResultado).html('<progress></progress>');
$('#' + idResultado).load("../AJAX/verificaCPF.php?campo1=" + busca, "",
function(responseText, textStatus, XMLHttpRequest) {
if(textStatus == 'error') {
$('#' + idResultado).html('<font color="red">(Erro de conexão com servidor. Tente novamente)</font>');
}
}
);
}
</script>
</head>
<body onload="selecionaCidade();">
<div id="menuInterno">
<?php
include '../Includes/MenuPrincipal.php';
?>
</div>
<div id="geral">
<div id="topo">
<div id="rodape">
</div>
</div>
<div id="conteudo">
<form id="form" name="form" method="post" action="../FilesOk/altClienteOK.php">
<div id="menuInterno">
<input type="submit" name="Submit" value="Alterar" class="gmailButton"/>
<input type="button" name="Submit2" value="Voltar" onclick="voltar()" class="gmailButton"/>
</div>
<table class="list">
<tr>
<td width="17%">Nome:</td>
<td width="36%">
<input name="nome" type="text" id="nome" value="<?php echo $objCliente->get('nome'); ?>" size="45" maxlength="45" />
<input name="codCliente" type="hidden" id="codCliente" value="<?php echo $_POST['codCliente']; ?>" />
</td>
<td width="9%">CPF:</td>
<td width="38%">
<input name="cpf" type="text" id="cpf" value="<?php echo $objCliente->get('cpf'); ?>" size="14" maxlength="14" onkeypress="mascaraCPF(this);" onblur="buscaAJAX(this.value, 'infoCPF');" />
<span id="infoCPF"></span>
</td>
</tr>
<tr>
<td>Logradouro:</td>
<td><input name="logradouro" type="text" id="logradouro" value="<?php echo $objCliente->get('logradouro'); ?>" size="45" maxlength="45" /></td>
<td>Número:</td>
<td><input name="numero" type="text" id="numero" value="<?php echo $objCliente->get('numero'); ?>" size="10" maxlength="10" /></td>
</tr>
<tr>
<td>Bairro:</td>
<td><input name="bairro" type="text" id="bairro" value="<?php echo $objCliente->get('bairro'); ?>" size="45" maxlength="45" /></td>
<td>Estado:</td>
<td><select name="estado" id="estado" onchange="selecionaCidade();">
<?php
for ($x = 0; $x < $contadorEstado; $x++) {
$objEstado = $objEstados[$x];
?>
<option value="<?php echo $objEstado->get('uf'); ?>" <?php
if ($objEstado->get('uf') == $objCliente->get("estado")) {
echo ('selected="selected"');
}
?>><?php echo $objEstado->get('nome'); ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Cidade:</td>
<td><label id="caixaCidade">
<select name="cidade" id="cidade" disabled="disabled">
<option value="Todos" selected="selected">Carregando...</option>
</select>
</label><label id="carregando"><img src="../Imagens/spinner_small.gif" width="16" height="16" /></label>
</td>
<td>Email:</td>
<td><input name="email" type="text" id="email" value="<?php echo $objCliente->get('email'); ?>" size="45" maxlength="45" /></td>
</tr>
<tr>
<td>CEP:</td>
<td colspan="3">
<input name="cep" type="text" id="cep" value="<?php echo $objCliente->get('cep'); ?>" size="10" maxlength="10" onkeypress="mascaraCEP(this);" />
<input type="button" onClick="open('buscaCEP.php', 'new', '')" value="Buscar..." class="gmailButton"/>
</td>
</tr>
<tr>
<td>Telefone:</td>
<td><input name="telefone" type="text" id="telefone" value="<?php echo $objCliente->get('telefone'); ?>" size="14" maxlength="14" onkeypress="mascaraTel(this);" /></td>
<td>Celular:</td>
<td><input name="celular" type="text" id="celular" value="<?php echo $objCliente->get('celular'); ?>" size="14" maxlength="14" onkeypress="mascaraCel(this);" /></td>
</tr>
<tr>
<td>Data de Nascimento:</td>
<td><input name="datNascimento" type="text" id="datNascimento" value="<?php echo $objCliente->get('datNascimento'); ?>" size="10" maxlength="10" onkeypress="mascaraData(this)" /></td>
<td>Identidade:</td>
<td><input name="identidade" type="text" id="identidade" value="<?php echo $objCliente->get('identidade'); ?>" size="15" maxlength="15" /></td>
</tr>
<tr>
<td>Sexo:</td>
<td>
<select name="sexo" id="sexo">
<option <?php
if ($objCliente->get('sexo') == "F")
echo "selected";
?> value="F">Feminino</option>
<option <?php
if ($objCliente->get('sexo') == "M")
echo "selected";
?> value="M">Masculino</option>
</select>
</td>
<td>Profissão:</td>
<td><input name="profissao" type="text" id="profissao" value="<?php echo $objCliente->get('profissao'); ?>" size="15" maxlength="30" /></td>
</tr>
<tr>
<td> </td>
<td>
<label for="usuario">Usuário:</label>
<input type="text" name="usuario" id="usuario" value="<?php echo $objCliente->get('usuario'); ?>" maxlength="10"/>
</td>
<td>
<label for="senha">Senha:</label>
<input type="text" name="senha" id="senha" maxlength="10"
value="<?php echo $objCliente->get('senha'); ?>"
/>
</td>
</tr>
<tr>
<td>OBS:</td>
<td colspan="3">
<textarea name="obs" id="obs" cols="60" rows="7" onkeyup="contOBS(this.value.length)"><?php echo $objCliente->get('obs'); ?></textarea><span id="contOBS" ></span>
</td>
</tr>
</table>
</form>
<a class="gmailButton" href="listAparelhoWhere.php?campo=cliente&operador==&&ordenar=dtVenda&valor=<?php echo $_POST['codCliente']; ?>">Listar Aparelhos</a>
</div>
</div>
</body>
</html>