<?php 
include_once 'CheckLogOut.php';
require_once 'Connection.php';
require_once 'ContactPhone.php';
// para atualizar a lista
require_once 'User.php';
require_once 'CacheArquivo.php';
////////////////////////////
require_once 'Log.php';
$con = new Connection();
$c = new ContactPhone();
$c->ContactId($_GET['contactId']);
$c->Sequential($_GET['sequential']);
$c->DeleteContactPhone();
// 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(3);
// log de deleção, conforme a tabela Actions
$Log->UserId($USERID);
//
$Log->InsertLog();
echo '<html>';
echo '<script language="JavaScript">';
echo 'window.location="Main.php"';
echo '</script>';
<?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>';
    if (isset($_GET['cpSeq']) && $_GET['cpSeq'] != '') {
        // update phone
        $contactPhone = new ContactPhone($_GET['phoneType'], $_GET['countryId'], $_GET['ddd'], $_GET['phoneNumber']);
        $contactPhone->ContactId($_GET['contactId']);
        $contactPhone->Sequential($_GET['cpSeq']);
        $contactPhone->UpdateContactPhone();
        $contactPhoneMessage = "Telefone " . $_GET['phoneNumber'] . " editado!";
        $Log2 = new Log(2);
        // log de update, conforme a tabela Actions
        $Log2->UserId($USERID);
        //
        $Log2->InsertLog();
    } else {
        // insert phone
        $contactPhone = new ContactPhone($_GET['phoneType'], $_GET['countryId'], $_GET['ddd'], $_GET['phoneNumber']);
        $contactPhone->ContactId($_GET['contactId']);
        $contactPhone->InsertContactPhone();
        $contactPhoneMessage = "Telefone " . $_GET['phoneNumber'] . " inserido!";
        $Log2 = new Log(1);
        // log de inserção, conforme a tabela Actions
        $Log2->UserId($USERID);
        //
        $Log2->InsertLog();
    }
}
// Endereço
if (isset($_GET['streetName']) && $_GET['streetName'] != '' && isset($_GET['number']) && $_GET['number'] != '') {
    if (isset($_GET['caSeq']) && $_GET['caSeq'] != '') {
        // update address
        $contactAdress = new ContactAdress($_GET['streetName'], $_GET['number'], $_GET['complement'], $_GET['checkPoint']);
        $contactAdress->ContactId($_GET['contactId']);