<?php

require 'Connection.php';
require 'Contact.php';
require 'ContactPhone.php';
require 'ContactAdress.php';
require 'Log.php';
$con = new Connection();
$Contact = new Contact($_REQUEST['fullName'], $_REQUEST['email'], $_COOKIE['USERID']);
$Contact->InsertContact();
$ContactPhone = new ContactPhone($_REQUEST['phoneType'], $_REQUEST['countryId'], $_REQUEST['ddd'], $_REQUEST['phoneNumber']);
$ContactPhone->ContactId($Contact->GetMaxContactId());
$ContactPhone->InsertContactPhone();
$ContactAdress = new ContactAdress($_REQUEST['streetName'], $_REQUEST['number'], $_REQUEST['complement'], $_REQUEST['checkPoint']);
$ContactAdress->ContactId($Contact->GetMaxContactId());
$ContactAdress->InsertContactAdress();
$Log = new Log(1);
// log de inserção, conforme a tabela Actions
$Log->UserId($_COOKIE['USERID']);
//
$Log->InsertLog();
echo '<html>';
echo '<h3> Contato inserido com sucesso! <h3>';
echo '<form action="Main.php">';
echo '<table>';
echo '	<tr>';
echo '		<td><input type="submit" value="Voltar à Página Inicial"> </input> </td>';
echo '	</tr>';
echo '</table>';
echo '</form>';
echo '</html>';
include_once 'CheckLogOut.php';
require_once 'Connection.php';
require_once 'ContactAdress.php';
// para atualizar a lista
require_once 'User.php';
require_once 'CacheArquivo.php';
////////////////////////////
require_once 'Log.php';
$con = new Connection();
$ca = new ContactAdress();
$ca->ContactId($_GET['contactId']);
$ca->StreetName($_GET['streetName']);
$ca->Number($_GET['number']);
$ca->Complement($_GET['complement']);
$ca->CheckPoint($_GET['checkPoint']);
$ca->InsertContactAdress();
// para atualizar a lista
$u = new User();
$cacheArquivo = new CacheArquivo();
$cacheArquivo->set_valor($UsId);
$Contacts = $u->GetAllContacts($USERID);
$valor = json_encode($Contacts);
$cacheArquivo->set_valor($USERID, $valor);
////////////////////////////
$Log = new Log(1);
// log de inserção, conforme a tabela Actions
$Log->UserId($USERID);
//
$Log->InsertLog();
echo '<html>';
echo '<script language="JavaScript">';