// Serching User Address
$nUser = searchByUserid($dbusercat, $matUser, $matAddr, $matComp, "", $userid, 1);
log_msg("number of users: " . $nUser . "Number of addresses:" . count($matAddr) . " AddrId = " . $matAddr[$address]->addressId . " Address: " . $address);
$CNPJ_CPF = $matUser[0]->CNPJ_CPF;
$compCNPJ = $matUser[0]->compCNPJ;
// $nAddr = searchAddressesByUserid($dbusercat, $matAddr, $userid);
$nAddr = searchAddrByCNPJ_CPF($dbusercat, $matAddr, $CNPJ_CPF, $compCNPJ);
if ($total > 0 and ($_SESSION['userType'] != 1 or $_SESSION['userType'] != 3)) {
    // Priced products and user not the System Manager
    // or Internal User.
    if ($nAddr == 0) {
        die("<br> <h3>{$strNoCPFCNPJ}<h3> <br>");
    }
}
// Instanciating Cart Group
$objCartG = new CartGroup($dbcat);
$objCartG->fill($sesskey, $userid);
// Verify Action
//if($action != $strCloseReq)
if ($action == $strContinue or $action == $strAdd) {
    ?>
<form name="cartAddressForm" method="POST" action="cartAddress.php">

<?php 
    // Showing Addresses
    if ($nAddr) {
        if ($mediaCD or $action == $strAdd) {
            ?>
         <br><h1><?php 
            echo $strDeliveryAddr;
            ?>
require "messageCat_" . $_SESSION['userLang'] . ".php";
// Globals
$dbcat = $GLOBALS["dbcatalog"];
$dbusercat = $GLOBALS["dbusercat"];
if ($GLOBALS["stationDebug"]) {
    echo "Session = {$PHPSESSID} User = "******" Language = " . $_SESSION['userLang'] . " <br>\n";
}
// Variables
$total = 0;
$nReqRefused = 0;
$userid = $_SESSION['userId'];
// Serching user
$objUser = new User($dbusercat);
$objUser->selectByUserId($userid);
// Instanciating Cart Group
$objCartG = new CartGroup($dbcat);
$objCartG->fill($sesskey, $userid);
$mediaCD = false;
// Showing cart itens
for ($i = 0; $i < $objCartG->nItens; $i++) {
    // cart itens
    $objCart = new Cart($dbcat);
    $objCart->search($objCartG->cart[$i]["Id"]);
    if ($objCart->media == "CD") {
        $mediaCD = true;
    }
    //Searching the scene
    $sql = "SELECT * FROM Scene WHERE SceneId='" . $objCart->sceneId . "'";
    $dbcat->query($sql) or $dbcat->error($sql);
    $itens = $dbcat->numRows();
    if ($itens == 0) {