<?php
    require_once('functions.php');
    require 'conexion.php';
    
    $id = $_POST['id'];
	$company = $_POST['company'];
	$cpf_cnpj = $_POST['cpf_cnpj'];
	$popular_name = $_POST['popular_name'];
	$address = $_POST['address'];
    $material = $_POST['material'];
	$hood = $_POST['hood'];
	$zip_code = $_POST['zip_code'];
	$city = $_POST['city'];
	$state = $_POST['state'];
	$ie = $_POST['ie'];
	$contact1 = $_POST['contact1'];
	$email1 = $_POST['email1'];
	$phone1 = $_POST['phone1'];
	$cell1 = $_POST['cell1'];
	$contact2 = $_POST['contact2'];
	$email2 = $_POST['email2'];
	$phone2 = $_POST['phone2'];
	$cell2 = $_POST['cell2'];
	$contact3 = $_POST['contact3'];
	$email3 = $_POST['email3'];
	$phone3 = $_POST['phone3'];
	$cell3 = $_POST['cell3'];
	$obs = $_POST['obs'];
	$type = $_POST['type'];    
	$ativo = isset($_POST['ativo']) ? $_POST['ativo'] : 0;
    
  

	$sql = "UPDATE companies SET type=(UPPER('$type')), material=(UPPER('$material')), company=(UPPER('$company')), cpf_cnpj='$cpf_cnpj', popular_name=(UPPER('$popular_name')), address=(UPPER('$address')), hood=(UPPER('$hood')), zip_code='$zip_code', city=(UPPER('$city')), state=(UPPER('$state')), ie='$ie', contact1=(UPPER('$contact1')), email1=(UPPER('$email1')), phone1=(UPPER('$phone1')), cell1=(UPPER('$cell1')), contact2=(UPPER('$contact2')), email2=(UPPER('$email2')), phone2=(UPPER('$phone2')), cell2=(UPPER('$cell2')), contact3=(UPPER('$contact3')), email3=(UPPER('$email3')), phone3=(UPPER('$phone3')), cell3=(UPPER('$cell3')), obs=(UPPER('$obs')), ativo='$ativo'  WHERE id = '$id'";
	//print_r ($sql);
    $resultado = $mysqli->query($sql);
?>

<html lang="es">
	<head>
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="row" style="text-align:center">
					<?php if($resultado) { ?>
						<META HTTP-EQUIV=REFRESH CONTENT = '0;URL=companies_index.php'>
						<?php } else { ?>
						<h3>******* ERROR AO REGISTRAR REGISTRO ********</h3>
                        <a href="companies_index.php" class="btn btn-primary">Por favor, contactar administrador e informar o código *companiessalvar*</a>
                    <?php } ?>
				</div>
			</div>
		</div>
	</body>
</html>