<!--// $Id$ //-->
{box title="Information about you"}
<FORM NAME="useredit" METHOD="POST" ACTION="?m=info&f=updateusersave">
<table width="100%" CELLPADDING="3" class="light">
{if $error}
	<tr>
		<td width="100%" COLSPAN="3">
{/if}
{if $error.ssn}
			<span class="text-center bold" style="color: red;">{trans("Incorrect Social Security Number!")}</span>
{/if}
{if $error.ten}
			<span class="text-center bold" style="color: red;">{trans("Incorrect Tax Exempt Number!")}</span>
{/if}
{if $error}
		</td>
	</tr>
{/if}
	<tr class="dark">
		<td width="1%" align="center">
			{img src="person.gif" alt=""}
		</td>
{if $rights.info.edit_addr || $rights.info.edit_addr_ack}
		<td width="99%">
			<TABLE cellpadding="0" cellspacing="2">
			    <TR>
				<TD><INPUT TYPE="TEXT" NAME="userdata[lastname]" VALUE="{$userinfo.lastname|escape}" SIZE="50" {userpaneltip text="Enter lastname"}></TD>
			    </TR>
			    <TR>
				<TD><INPUT TYPE="TEXT" NAME="userdata[name]" VALUE="{$userinfo.name|escape}" SIZE="50" {userpaneltip text="Enter first name"}></TD>
			    </TR>
			</TABLE>
{else}
		<td width="99%" colspan="2">
			<strong>{$userinfo.customername} ({$userinfo.id|string_format:"%04d"})</strong>
{/if}
		</td>
	</tr>
	<tr>
		<td width="1%" align="center">
			{img src="mail.gif" alt=""}
		</td>
		<td width="99%">
{if $rights.info.edit_contact || $rights.info.edit_contact_ack}
			<TABLE cellpadding="0" cellspacing="2">
			{foreach $userinfo.emails as $email}
				<TR><TD><INPUT type="email" NAME="userdata[email][{$email.id}]" VALUE="{$email.email}" SIZE="50" {userpaneltip text="Enter email address"}></TD></TR>
			{foreachelse}
				<TR><TD><INPUT type="email" NAME="userdata[email][0]" VALUE="{$userinfo.email}" SIZE="50" {userpaneltip text="Enter email address"}></TD></TR>
			{/foreach}
			</TABLE>
{else}
			{foreach $userinfo.emails as $email}
				{$email.email}{if !$email@last}<BR />{/if}
			{/foreach}
{/if}
		</td>
	</tr>
	<tr class="dark">
{if $rights.info.edit_addr || $rights.info.edit_addr_ack}
		<td width="1%" align="center">
			{img src="address.gif" alt=""}
		</td>
		<td width="99%">
			<TABLE cellpadding="0" cellspacing="2">
				<TR>
					<TD width="1%">{trans("Street:")}</TD>
					<TD width="99%"><INPUT TYPE="TEXT" NAME="userdata[street]" VALUE="{$userinfo.street}" SIZE=40 {userpaneltip text="Enter street name"}></TD>
				</TR>
				<TR>
					<TD width="1%">{trans("Building:")}</TD>
					<TD width="99%">
						<INPUT TYPE="TEXT" NAME="userdata[building]" VALUE="{$userinfo.building}" SIZE=8 {userpaneltip text="Enter building number"}>
						{trans("Apartment:")}
						<INPUT TYPE="TEXT" NAME="userdata[apartment]" VALUE="{$userinfo.apartment}" SIZE=8 {userpaneltip text="Enter apartment number"}>
					</TD>
				</TR>
			    <TR>
				<TD width="1%">{trans("Zip:")}</TD>
				<TD width="99%"><INPUT TYPE="TEXT" NAME="userdata[zip]" VALUE="{$userinfo.zip}" SIZE=40 {userpaneltip text="Enter zip code"}></TD>
			    </TR>
			    <TR>
				<TD width="1%">{trans("City:")}</TD>
				<TD width="99%"><INPUT TYPE="TEXT" NAME="userdata[city]" VALUE="{$userinfo.city}" SIZE=40 {userpaneltip text="Enter city name"}></TD>
			    </TR>
			</TABLE>
{else}
		<td width="1%" align="center">
			{img src="address.gif" alt=""}
		</td>
		<td width="99%">
			{$userinfo.address}<br/>
			{$userinfo.zip} {$userinfo.city}
{/if}
		</td>
	</tr>
	<tr>
		<td width="1%" align="center">
			{img src="phone.gif" alt=""}
		</td>
		<td width="99%">
{if $rights.info.edit_contact || $rights.info.edit_contact_ack}
			<TABLE cellpadding="0" cellspacing="2">
			    {foreach from=$userinfo.contacts item=item}
			    <TR><TD><INPUT TYPE="TEXT" NAME="userdata[phone][{$item.id}]" VALUE="{$item.phone}" {userpaneltip text="Enter phone number"}></TD></TR>
			{foreachelse}
			    <TR><TD><INPUT TYPE="TEXT" NAME="userdata[phone][0]" VALUE="{$userinfo.phone}" {userpaneltip text="Enter phone number"}></TD></TR>
			{/foreach}
			</TABLE>
{else}
			{foreach from=$userinfo.contacts item=item}
			        {if $item.phone}{$item.phone}<BR />{/if}
			{/foreach}
{/if}
		</td>
	</tr>
{foreach $userinfo.ims as $item}
	<tr class="dark">
		<td width="1%" align="center">
			{if $item.type & $smarty.const.CONTACT_IM_GG}
			{img src="gg.gif" alt=""}
			{elseif $item.type & $smarty.const.CONTACT_IM_YAHOO}
			{img src="yahoo.gif" alt=""}
			{elseif $item.type & $smarty.const.CONTACT_IM_SKYPE}
			{img src="skype.gif" alt=""}
			{/if}
		</td>
		<td width="99%">
{if $rights.info.edit_contact || $rights.info.edit_contact_ack}
			<INPUT TYPE="TEXT" NAME="userdata[im][{$item.id}]" VALUE="{$item.uid}" {userpaneltip text="Enter IM number"}>
{else}
			{$item.uid}
{/if}
		</td>
	</tr>
{/foreach}
	<tr>
		<td width="1%" align="center">
			<strong>{trans("TEN")}</strong>
		</td>
		<td width="99%">
{if $rights.info.edit_addr || $rights.info.edit_addr_ack}
			<INPUT TYPE="TEXT" NAME="userdata[ten]" VALUE="{$userinfo.ten}" {userpaneltip text="Enter tax exempt number"}>
{else}
			{$userinfo.ten}
{/if}
		</td>
	</tr>
	{if ConfigHelper::checkConfig('userpanel.show_customer_sensitive_data') || ($rights.info.edit_addr || $rights.info.edit_addr_ack)}
		<tr class="dark">
			<td width="1%" align="center">
				<strong>{trans("SSN")}</strong>
			</td>
			<td width="99%">
				{if $rights.info.edit_addr || $rights.info.edit_addr_ack}
					<INPUT TYPE="TEXT" NAME="userdata[ssn]" VALUE="{$userinfo.ssn}"  {userpaneltip text="Enter social security number"}>
				{else}
					{if ConfigHelper::checkConfig('userpanel.show_customer_sensitive_data')}
						{$userinfo.ssn}
					{/if}
				{/if}
			</td>
		</tr>
	{/if}
{if $rights.info.edit_addr ||
    $rights.info.edit_addr_ack ||
    $rights.info.edit_contact ||
    $rights.info.edit_contact_ack
}
	<tr>
		<td width="99%" colspan="2" align="right">
			<a href="#" id="updateuserbtn" accesskey="A">{trans("Save")} {img src="edit.gif" alt=""}</a>
		</td>
	</tr>
{/if}
</table>
</FORM>
<script>

	$('#updateuserbtn').click(function() {
		var emails = $('input[type="email"]');
		var invalid = emails.length;
		emails.each(function() {
			if (this.checkValidity()) {
				invalid--;
			}
		});
		if (invalid) {
			return false;
		} else {
			document.useredit.submit();
		}
	});

</script>
{/box}
