Viewing file: fornecedor_cad.php (21.07 KB) -rwxr-xr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
// Includes
include("../../config/config.php");
include(INCLUDES . "inc_Funcoes.php");
include(INCLUDES . "inc_Conexao.php");
include(INCLUDES . "valida_usuario.inc.php");
if ($_GET['idFor']) {
$idFor = $_GET['idFor'];
$labelBotao = 'Alterar';
$where = "FOR_RowID = $idFor";
$fornecedores = lista('FUN_Fornecedores',$where);
foreach($fornecedores as $fornecedor) {
$fornecedor = $fornecedor;
}
extract($fornecedor);
//busca os grupos vinculados ao distribuidor
$where = "VFG_Fornecedor_DR = $idFor AND VFG_AtivoSN = 'S'";
$rsGruposVinculado = lista('FUN_VinculaFornecedorGrupo',$where);
if (!empty($rsGruposVinculado)) {
foreach($rsGruposVinculado as $rsGruposVinculado) {
$gruposVinc[] = $rsGruposVinculado['VFG_Grupo_DR'];
}
} else {
$gruposVinc[] = '';
}
} else
$labelBotao = 'Salvar';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Description" content="IRPEN">
<meta name="Keywords" content="">
<meta name="resource-type" content="document">
<meta name="classification" content="Internet">
<meta name="robots" content="all">
<meta name="rating" content="General">
<meta name="Author" content="Ninart! Solucoes para Web.">
<meta name="language" content="pt-br">
<link rel="shortcut icon" href="imagens/favicon.gif"type="image/gif">
<link rel="stylesheet" href="<?= HOST;?>css/irpen.css" type="text/css" />
<link rel="stylesheet" media="all" type="text/css" href="<?= HOST;?>css/menu_dropline.css" />
<link type="text/css" href="<?= HOST;?>css/jquery-ui/ui.all.css" rel="Stylesheet" />
<!--[if IE]>
<link rel="stylesheet" media="all" type="text/css" href="css/menu_dropline_ie.css" />
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" media="all" type="text/css" href="css/menu_dropline_ie6.css" />
<![endif]-->
<title>IRPEN | Instituto de Registro Civil de Pessoas Naturais do Paraná - 2008</title>
<script type="text/javascript" src="<?= HOST;?>includes/jquery.js"></script>
<script type="text/javascript" src="<?= HOST;?>includes/jquery.bestupper.min.js"></script>
<script type="text/javascript" src="<?= HOST;?>includes/funcoes.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.bestupper').bestupper();
$('.bestlower').bestlower();
$('#CID_Nome').focus();
});
function validaForm() {
var contador = 0;
$(".opcGrupos").each(function() {
if ($(this).is(':checked')) {
contador++;
}
});
if (contador == 0) {
alert('É necessário vincular o Fornecedor a pelo menos 1(um) grupo');
return false;
}
if ($('#FOR_CpfCnpj').val() == '') {
alert('Digite o CPF/CNPJ do Fornecedor!');
$('#FOR_CpfCnpj').focus();
return false;
} else
if ($('#FOR_Nome').val() == '') {
alert('Digite o Nome do Fornecedor!');
$('#FOR_Nome').focus();
return false;
} else {
$('#salvar').attr('disabled',true);
$('#frmCadastroFornecedor').submit();
/*var data = $('#form1').serialize();
$.post('fornecedor_grava.php', data, function(data){
$('#result').html(data);
});*/
return false;
}
return false;
}
function alteraStatus(acao,id) {
if (acao == 'Inativar')
txt = 'inativação';
else
txt = 'ativação';
if (confirm('Confirma '+txt+' deste Fornecedor?')) {
//alert(acao+' Fornecedor');
$('#result').load('fornecedor_grava.php?id='+id+'&acao='+acao);
}
}
// ********** FUNCAO QUE REALIZA A VALIDACAO TANTO DE CPF COMO DE CNPJ **********
function Verifica_CPF_CGC(field)
{
var cpf='', cgc='', digito='', digitoc='', temp='', k=0; i=0, j=0, soma=0, mt=0, dg='';
field.value = Trim(field.value);
campo = field.value;
tam = campo.length;
var textos = ""
for (j=0;j<=tam;j++)
{
if(campo.substring(j,j+1) != " ")
{
textos = textos + campo.substring(j,j+1)
}
}
field.value = textos;
// Cria expressões regulares para remover a formatação do campo
re = /\./g;
field.value = field.value.replace(re, "");
re = /\-/g;
field.value = field.value.replace(re, "");
re = /\//g;
field.value = field.value.replace(re, "");
// Limpa os espacos da variavel
if (field.value == ' ' || field.value == ' ' || field.value == ''){
return false;
}
else {
cpf = field.value;
}
if (cpf.length == 19) {
cpf = cpf.substring(1, cpf.length)
}
for (i = 0;i < cpf.length; i++) {
k = i + 1;
if (isNaN(cpf.substring(i,k))== false){
temp = temp + cpf.substring(i,k);
}
}
if (((cpf.length > 13) && (cpf.length < 19)) && (isNaN(cpf.substring(3,4))==false)){
cgc = temp.substring(0,12);
digito = temp.substring(12,14);
mult = '543298765432';
for (j = 1; j <= 2; j++) {
soma = 0;
for (i = 0; i <= 11; i++) {
k = i + 1;
soma += parseInt((cgc.substring(i,k)) * (mult.substring(i,k)));
}
if (j == 2){
soma = soma + (2 * digitoc);
}
digitoc = ((soma * 10) % 11);
if (digitoc == 10){
digitoc = 0;
}
dg +=digitoc;
mult = '654329876543';
}
if (dg != digito || TudoIgual(field)) {
alert('Informação inválida!');
//field.value = '';
field.focus();
return false;
}
else {
field.value=temp.substring(0,2)+'.'+temp.substring(2,5)+'.'+temp.substring(5,8)+'/'+temp.substring(8,12)+'-'+temp.substring(12,14);
return true;
}
}
else {
if (cpf.length < 11) {
alert('Informação inválida!');
//field.value = '';
field.focus();
return false;
}
if (cpf.length >= 11) {
cpf = temp.substring(0,9);
digito = temp.substring(9,11);
for (j = 1; j <= 2; j++) {
soma = 0;
mt = 2;
for (i = 8 + j; i >= 1; i--) {
soma += parseInt(cpf.charAt(i-1),10) * mt;
mt++;
}
dg = 11 - (soma % 11);
if (dg > 9) {dg = 0};
cpf += dg;
}
if (digito != cpf.substring(9,11) || TudoIgual(field)) {
alert('Informação inválida!');
//field.value = '';
field.focus();
return false;
}
else {
field.value=cpf.substring(0,3)+'.'+cpf.substring(3,6)+'.'+cpf.substring(6,9)+'-'+cpf.substring(9,11);
return true;
}
}
} // fim if (cpf.length < 15)
}
// ********** FUNÇÃO QUE VERIFICA SEMELHANÇA ENTRE STRINGS *************
function TudoIgual(field) {
var str = field.value, primeiro='';
for(i = 0; i < str.length; i++)
if (str.charAt(i)>='0' && str.charAt(i)<='9')
if (primeiro=='') primeiro = str.charAt(i);
else if (str.charAt(i) != primeiro) return 0;
return 1;
}
function Trim(s) {
if (s.length == 0)
return s;
if (s.length == 1 && s.value == ' ')
return '';
var i=0;
while ( i < s.length && s.substring(i,i+1) == ' ') i++;
var f = s.length - 1;
while ( f >= 0 && s.substr(f,f+1) == ' ') f--;
s = s.substr(i,f+1);
return s;
}
function cpfcnpj(){
documento = $('#FOR_CpfCnpj').val();
if(documento.length == 3){
$('#FOR_CpfCnpj').val(documento + '.');
return false;
}
if(documento.length == 7){
$('#FOR_CpfCnpj').val(documento + '.');
return false;
}
if(documento.length == 11){
$('#FOR_CpfCnpj').val(documento + '-');
return false;
}
if(documento.length == 15){
p0=documento.charAt(0);
p1=documento.charAt(1);
p2=documento.charAt(2);
p3=documento.charAt(4);
p4=documento.charAt(5);
p5=documento.charAt(6);
p6=documento.charAt(8);
p7=documento.charAt(9);
p8=documento.charAt(10);
p9=documento.charAt(12);
p10=documento.charAt(13);
p11=documento.charAt(14);
$('#FOR_CpfCnpj').val('');
$('#FOR_CpfCnpj').val(p0 + p1 + '.' + p2 + p3 + p4 + '.' + p5 + p6 + p7 + '/' + p8 + p9 + p10 + p11 + '-' );
p0='';
p1='';
p2='';
p3='';
p4='';
p5='';
p6='';
p7='';
p8='';
p9='';
p10='';
p11='';
return false;
}
}
function isEmailValid(campo){
if ($('#'+campo).val() != '') {
strEmail = $('#'+campo).val();
validRegExp = /^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/;
// search email text for regular exp matches
if (strEmail.search(validRegExp) == -1) {
alert('Email invalido');
$('#'+campo).val('');
$('#'+campo).focus();
return false;
}
return true;
}
}
</script>
<style type="text/css">
<!--
.style1 {
color: #666666;
font-weight: bold;
}
-->
</style>
</head>
<body>
<div id="wrap">
<?php include "../topo_gestao.php";?>
<!-- content-wrap starts -->
<div id="content-wrap">
<table width="100%" border="0">
<tr>
<td align="left" valign="top" bgcolor="#FFFFFF" width="1%"> </td>
<td align="left" valign="top">
<table width="100%" border="0" >
<tr>
<td align="" valign="top"><h2>Cadastro de fornecedor</h2></td>
<div id="linha_h2" align="center">
<form name="frmCadastroFornecedor" id="frmCadastroFornecedor" method="post" action="fornecedor_grava.php" onsubmit="return validaForm()" target="recipiente">
<p>
<table width="50%" border="0" align="center" cellpadding="3" cellspacing="5" class="tabela">
<tr>
<td width="100%" colspan="4" align="center"><h3>Cadastro de fornecedor</h3></td>
</tr>
<tr>
<td align="right">CPF/CNPJ<span style="color: #FF0066">*</span>:
<input name="FOR_RowID" type="hidden" id="FOR_RowID" value="<?= $FOR_RowID?>" /></td>
<td align="left"><input name="FOR_CpfCnpj" type="text" id="FOR_CpfCnpj" onblur="return Verifica_CPF_CGC(this)" onkeyup="cpfcnpj()" value="<?= $FOR_CpfCnpj?>" size="25" maxlength="18" /></td>
</tr>
<tr>
<td align="right">Nome<span style="color: #FF0066">*</span>: </td>
<td align="left"><input name="FOR_Nome" type="text" id="FOR_Nome" size="35" value="<?= utf8_decode($FOR_Nome)?>" class="bestupper" /></td>
</tr>
<tr>
<td align="right">Banco: </td>
<td align="left">
<select name="FOR_Banco_DR" id="FOR_Banco_DR">
<option value="">--- SELECIONE ---</option>
<?php
$where = "BAN_AtivoSN = 'S'";
$order = "BAN_Nome";
$rsBanco = lista('FUN_Bancos',$where,$order);
if (!empty($rsBanco)) {
foreach($rsBanco as $banco) {
extract($banco);
?>
<option value="<?= $BAN_RowID?>" <?= ($BAN_RowID == $FOR_Banco_DR) ? 'selected="selected"' : '' ?>><?= $BAN_Nome?></option>
<?php
}
}
?>
</select>
</td>
</tr>
<tr>
<td align="right">Agência: </td>
<td align="left"><input name="FOR_AgenciaNum" type="text" id="FOR_AgenciaNum" size="10" value="<?= $FOR_AgenciaNum?>" />
-
<input name="FOR_AgenciaDV" type="text" id="FOR_AgenciaDV" size="4" value="<?= $FOR_AgenciaDV?>" /></td>
</tr>
<tr>
<td align="right">Conta: </td>
<td align="left"><input name="FOR_ContaNum" type="text" id="FOR_ContaNum" size="10" value="<?= $FOR_ContaNum?>" />
-
<input name="FOR_ContaDV" type="text" id="FOR_ContaDV" size="4" value="<?= $FOR_ContaDV?>" /></td>
</tr>
<tr>
<td align="right">Endereço: </td>
<td align="left"><input name="FOR_Endereco" type="text" id="FOR_Endereco" size="35" value="<?= utf8_decode($FOR_Endereco)?>" class="bestupper" /></td>
</tr>
<tr>
<td align="right">Complemento: </td>
<td align="left"><input name="FOR_Complemento" type="text" id="FOR_Complemento" size="35" value="<?= utf8_decode($FOR_Complemento)?>" class="bestupper" /></td>
</tr>
<tr>
<td align="right">Cidade: </td>
<td align="left"><select name="FOR_Cidade_DR" id="FOR_Cidade_DR">
<option value="">--- SELECIONE ---</option>
<?php
$where = 'CID_ComarcaMunicipioDistritoCMD IN ("C","M")';
$order = 'CID_Descricao ASC';
$cidades = lista('cidades',$where,$order);
foreach ($cidades as $cidade) {
?>
<option value="<?= $cidade['CID_RowID']?>"
<?php
if ($cidade['CID_RowID'] == $FOR_Cidade_DR) {
echo ' selected="selected"';
}
?>
>
<?= utf8_decode($cidade['CID_Descricao'])?>
</option>
<?php
}
?>
</select></td>
</tr>
<tr>
<td align="right">CEP: </td>
<td align="left"><input name="FOR_CEP" type="text" id="FOR_CEP" onkeypress="return txtBoxFormat(this, '99999-999', event);" value="<?= $FOR_CEP?>" size="9" maxlength="9" /></td>
</tr>
<tr>
<td align="right">E-mail: </td>
<td align="left"><input name="FOR_Email" type="text" id="FOR_Email" size="35" value="<?= $FOR_Email?>" onblur="return isEmailValid(this.id)" class="bestlower" /></td>
</tr>
<tr>
<td align="right">Contato: </td>
<td align="left"><input name="FOR_Contato" type="text" id="FOR_Contato" size="35" value="<?= utf8_decode($FOR_Contato)?>" class="bestupper" /></td>
</tr>
<tr>
<td align="right">Telefone: </td>
<td align="left"><input name="FOR_DDD" type="text" class="bestupper" id="FOR_DDD" value="<?= $FOR_DDD?>" onkeypress="return txtBoxFormat(this, '99', event);" size="2" maxlength="2" />
-
<input name="FOR_Telefone" type="text" class="bestupper" id="FOR_Telefone" value="<?= $FOR_Telefone?>" size="9" maxlength="9" onkeypress="return txtBoxFormat(this, '9999-9999', event);" />
<input name="FOR_AtivoSN" type="hidden" id="FOR_AtivoSN" value="<?= $FOR_AtivoSN?>" /></td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<tr>
<td colspan="2" align="center"><h2>Vincular Fornecedor -> Grupos</h2></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2">
<?php
//busca os grupos cadastrados
$where = "GFO_AtivoSN = 'S'";
$rsGrupos = lista('FUN_GruposFornecedores',$where);
/*
echo "<pre>";
print_r($rsGrupos);
echo "</pre>";
*/
if (!empty($rsGrupos)) {
foreach($rsGrupos as $rsGrupos) {
extract($rsGrupos);
?>
<div style="width:50%; float:left;">
<input type="checkbox" name="chkGrupo[]" id="chkGrupo_<?= $GFO_RowID?>" value="<?= $GFO_RowID?>" <?= is_array($gruposVinc) && in_array($GFO_RowID,$gruposVinc) ? 'checked="checked"' : ' '?> style="margin:2px;" class="opcGrupos" />
<label for="chkGrupo_<?= $GFO_RowID?>"><?= $GFO_Nome?></label>
</div>
<?php
}
}
?>
</td>
</tr>
<?php if ($FOR_RowID != '') { ?><!--
<tr>
<td>Status:</td>
<td><?= ($FOR_AtivoSN == 'S' || $FOR_AtivoSN == '') ? 'Ativo' : 'Inativo' ?></td>
</tr> -->
<?php } else { echo '<input type="hidden" name="FOR_AtivoSN" id="FOR_AtivoSN" value="S" />';}?>
</table>
<p> </p>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td align="center"><input type="submit" name="salvar" id="salvar" value="<?= $labelBotao?>" />
<?php if ($FOR_RowID != '') { ?>
<input type="button" name="btnStatus" id="btnStatus" value="<?= ($FOR_AtivoSN == 'S') ? 'Inativar' : 'Ativar' ?>" onclick="alteraStatus(this.value,'<?= $FOR_RowID?>');" />
<?php } ?>
<input type="button" name="voltar" id="voltar" value="Voltar" onclick="window.location = 'lista_fornecedores.php'" /></td>
</tr>
</table>
</p>
</form>
</div>
</td>
</tr>
</table>
<br />
</td>
</tr>
</table>
</div>
<iframe name="recipiente" id="recipiente" width="0" height="0"></iframe>
<div align="center">
<strong><br />
Rua Mal. Deodoro, 51 - Galeria Ritz - 18º Andar | Fone: (41) 3232-9811 | CEP 80.020-905 - Curitiba - Paraná</strong>
<!-- content-wrap ends-->
</div>
<!-- footer starts -->
<div id="footer-wrap"></div>
<div id="rodape"></div>
</div>
<div id="result"></div>
</body>
</html>
|