<?php
include("postget.php");
include_once("common.php");

$thisclient = 1;

checklevel(1, $_REQUEST['clientid']);

if ($_REQUEST[emailing] == 1) {
    $query = "UPDATE hd_clients SET promotionalmailing='1' WHERE clientid='" . $_SESSION['hd_clientid'] . "'";
    if (!mysql_query($query, $db_link)) {
        messagetop(_ERROR, mysql_error(), 'index.php', 0);
    } else {
        messagetop(lang('_THE_CHANGES_WHERE_MADE_SUCCESSFULLY'), '', 'index.php', 1);
    }
}

$cliente = collectdata('client', $_SESSION['hd_clientid']);

include("head_template.php");
echo '<div class="container">
    <div class="row">';

print("<br><br><a href='" . $serverurl . "/editclient.php?clientid=" . $_SESSION['hd_clientid'] . "' class='btn'>" . ucfirst(_EDIT) . "</a>");
print(" <a href='" . $serverurl . "/clientdata.php?clientid=" . $_SESSION['hd_clientid'] . "' class='btn'>" . ucfirst(_CHANGES_HISTORY) . "</a>");
print(" <a href='" . $serverurl . "/events.php?clientid=" . $_SESSION['hd_clientid'] . "' class='btn'>" . ucfirst(_LOG) . "</a>");

if ($_SESSION['hd_accesslvl'] > 1) {
    print(" <a class='btn' href='" . $serverurl . "/duplicatedclients.php?clientid=$cliente[clientid]&first=$cliente[first]&last=$cliente[last]&address=$cliente[address]&phone=$cliente[phone]&email=$cliente[email]'
	target='_blank' 
	onClick=\"window.open(this.href, this.target, 'width=800, height=600, left=20, top=20, scrollbars=1'); 
	return false;\">
	" . _CHECK_DUPLICATES . "</a>");
}


print('<table class="table table-striped">');
print("<thead><tr>");
print("
<th>" . _CLIENT_ID . "</th>
<th>" . _FIRST_NAME . "</td>    
<th>" . _LAST_NAME . "</th>
<th>" . _ADDRESS . "</th>
<th>" . _CITY . "</th> 
<th>" . lang('_STATE') . "</th>
<th>" . _COUNTRY . "</th>");
print("<tr></thead>");
print("<tbody><tr>");

print("<td>" . $cliente[clientid] . "</td>");
print("<td>" . $cliente[firstname] . "</td>");
print("<td>" . $cliente[lastname] . "</td>");
print("<td>" . $cliente[address] . "</td>");
print("<td>" . $cliente[city] . ($cliente[zip] ? ' (' . $cliente[zip] . ')' : '') . "</td>");
print("<td>" . $cliente[state] . "</td>");
print("<td>" . $cliente[country] . "</td>");
print("</tr></tbody>");
print("</table>");



print('<table class="table table-striped">');

print("<thead><tr>");
print("
<th>" . _PHONE . "</th>
<th>" . _COMPANY . "</th>   
<th>" . _EMAIL . "</th>
<th>" . _PASSWORD . "</th>");
print("<tr></thead>");
print("<tbody><tr>");

print("<td>(" . $cliente[phonecode] . ") " . $cliente[phone] . "</td>");
print("<td>" . $cliente[company] . "</td>");
print("<td>" . $cliente[email] . "");
if ($_SESSION['hd_accesslvl'] > 1) {
    print("&nbsp;
        &nbsp;
        <a class='btn' href = '" . $serverurl . "/markasspam.php?type=Email&text=" . $cliente[email] . "'
        target = '_blank'
        onClick = \"window.open(this.href, this.target, 'width=400, height=200, left=200, top=200, scrollbars=1'); 
	return false;\">
	" . strtolower(_MARK_AS_SPAM) . "</a>");
}
print("<td>" . $cliente[password] . "");
if ($_SESSION['hd_accesslvl'] > 1) {
    print("&nbsp;&nbsp;
    <a class='btn' href='" . $serverurl . "/passgenerate.php?clientid=" . $_SESSION['hd_clientid'] . "'>
    <font color='" . $textinfoot . "'>" . strtolower(_SEND) . "</font></a>");
}
print("</td>");
print("</tr></tbody>");
print("</table>");













print('<table class="table">');
print("<thead><tr>");
if ($config[41][1]) {
    print("<th>" . $config[41][1] . "</th>");
}
if ($config[42][1]) {
    print("<th>" . $config[42][1] . "</th>");
}
if ($config[43][1]) {
    print("<th>" . $config[43][1] . "</th>");
}
if ($config[44][1]) {
    print("<th>" . $config[44][1] . "</th>");
}
if ($config[45][1]) {
    print("<th>" . $config[45][1] . "</th>");
}
print("<tr></thead>");
print("<tbody><tr>");

if ($config[41][1]) {
    print("<td>" . $cliente[personalized_1] . "</td>");
}
if ($config[42][1]) {
    print("<td>" . $cliente[personalized_2] . "</td>");
}
if ($config[43][1]) {
    print("<td>" . $cliente[personalized_3] . "</td>");
}
if ($config[44][1]) {
    print("<td>" . $cliente[personalized_4] . "</td>");
}
if ($config[45][1]) {
    print("<td>" . $cliente[personalized_5] . "</td>");
}
print("</tr></tbody>");
print("</table>");





if ($cliente['promotionalmailing'] == 0 AND $_SESSION['hd_accesslvl'] == 1) {
    print("<br><br><a href='" . $serverurl . "/clientdata2.php?emailing=1' class='btn'>" . lang('_reverse_promotional_mailings') . "</a><br><br>");
}

echo '</div>';
echo '</div>';
include("foot_template.php");
?>  