<!--// $Id$ //-->

{css}
{js}

<FORM method="post" action="" name="custnodeslist" id="custnodeslist-form">
</FORM>

{$lastonline_limit=ConfigHelper::getConfig('phpui.lastonline_limit')}
{if ConfigHelper::checkConfig('phpui.ewx_support')}{assign var=ewx value=1}{else}{assign var=ewx value=0}{/if}

{tab_container id="customernodesbox" label="Customer Nodes"}

	{tab_header content_id="nodespanel-`$layout.module`"}
		{tab_header_cell icon="lms-ui-icon-node"}
			<strong>{t a=$customernodes|size}Customer Nodes ($a){/t}</strong>
		{/tab_header_cell}
		{tab_header_cell}
			{if $customerinfo.status != $smarty.const.CSTATUS_INTERESTED && ! $customerinfo.deleted}
				<a href="?m=nodeadd&ownerid={$customerinfo.id}">
					{trans("New Node")}
					{icon name="next" class="fa-fw"}
				</a>
			{/if}
		{/tab_header_cell}
	{/tab_header}

	{tab_contents id="nodespanel-`$layout.module`"}

		{tab_table}

			{if $customernodes}
			<div class="lms-ui-tab-table-row header">
				<div class="lms-ui-tab-table-wrapper col-7">
					<div class="lms-ui-tab-table-wrapper col-3">
						<div class="lms-ui-tab-table-column name">
							{trans("Name:")}
						</div>
						<div class="lms-ui-tab-table-column id">
							{trans("ID:")}
						</div>
						{if $ewx}
						<div class="lms-ui-tab-table-column channel">
							{trans("Channel:")}
						</div>
						{/if}
					</div>

					<div class="lms-ui-tab-table-wrapper col-4">
						<div class="lms-ui-tab-table-wrapper col-2">
							<div class="lms-ui-tab-table-column address">
								{trans("Address:")}
							</div>
							<div class="lms-ui-tab-table-column mac">
								{trans("MAC:")}
							</div>
						</div>
						<div class="lms-ui-tab-table-wrapper col-2">
							<div class="lms-ui-tab-table-column groups">
								{trans("Groups:")}
							</div>
							<div class="lms-ui-tab-table-column network">
								{trans("Network:")}
							</div>
						</div>
					</div>
				</div>

				<div class="lms-ui-tab-table-column buttons">
					&nbsp;
				</div>
			</div>
			{/if}

			{foreach $customernodes as $node}
			<div class="lms-ui-tab-table-row{if !$node.access} blend{/if}" data-target-url="?m=nodeinfo&id={$node.id}">
				<div class="lms-ui-tab-table-wrapper col-7">
					<div class="lms-ui-tab-table-wrapper col-3">
						<div class="lms-ui-tab-table-column name">
							{if $node.lastonline}
								{if ($smarty.now-$node.lastonline) > $lastonline_limit}
									{button icon="nodeoff" type="link" class="lms-ui-ignore-target-url"
										onclick="ping_popup('{$node.ip}')" label=$node.name
										tip="{trans("Last online:")} {$node.lastonline_date}"}
								{else}
									{button icon="nodeon" type="link" class="lms-ui-ignore-target-url"
										onclick="ping_popup('{$node.ip}')" label=$node.name tip="online"}
								{/if}
							{else}
								{button icon="nodeunk" type="link" class="lms-ui-ignore-target-url"
									onclick="ping_popup('{$node.ip}')" label=$node.name tip="unknown"}
							{/if}
							{if $node.locked}{icon name="lock" tip="<!node>lock is active" class="node-lock-icon"}{/if}
							{if isset($nodeassignments[$node.id])}
								({foreach $nodeassignments[$node.id] as $assignment}<a href="?m=customerassignmentedit&id={$assignment.id}"><span
										class="lms-ui-ignore-target-url{if ($assignment.dateto < $smarty.now && $assignment.dateto) || ($assignment.liabilityid && $assignment.at < $smarty.now && $assignment.at > 365)} blend{elseif ($assignment.datefrom > $smarty.now && $assignment.datefrom && $assignment.period) && !($assignment.suspended)} alertblend{elseif ($assignment.suspended)}suspended{/if}
										{if !$assignment.commited} lms-ui-assignment-not-commited{/if}">{$assignment.name}</span></a>{if !$assignment@last}, {/if}{/foreach})
							{/if}
							{if $node.location}<BR>
								<span class="nobr" class="lms-ui-ignore-target-url">
									{if $node.teryt}
										{button icon="map" type="link" href="?m=netdevmap&nodeid={$node.id}"} {t a=$node.location|trunescape:60}$a (TERYT){/t}</a>
									{else}
										{button icon="map" type="link" href="?m=netdevmap&nodeid={$node.id}" label="{$node.location|trunescape:60}" }
									{/if}
								</span>
							{/if}
							{if $node.info}<BR>
								<span class="nobr lms-ui-ignore-target-url">{$node.info|truncate:60:"&hellip;":true}</span>
							{/if}
						</div>
						<div class="lms-ui-tab-table-column id">
							({$node.id|string_format:"%04d"})
						</div>
						{if $ewx}
							<div class="lms-ui-tab-table-column channel">
								{if $node.channelname}
									<a href="?m=ewxchinfo&amp;id={$node.channelid}">{$node.channelname|truncate:30:"&hellip;":true}</a>
								{elseif $node.channelid}
									{if !$node.cid}
										<a href="?m=ewxchinfo&amp;id=0">[{trans("default")}]</a>
									{else}
										[{$node.channelid|string_format:"%04d"}]
									{/if}
								{/if}
								{if $node.downceil}({$node.downceil}/{$node.upceil|default:0} kbit/s){/if}
							</div>
						{/if}
					</div>

					<div class="lms-ui-tab-table-wrapper col-4">
						<div class="lms-ui-tab-table-wrapper col-2">
							<div class="lms-ui-tab-table-column address">
								{$node.ip} {if $node.ip_pub != "0.0.0.0"} ({$node.ip_pub}){/if}
							</div>
							<div class="lms-ui-tab-table-column mac">
								{$node.mac|replace:",":"<BR>"}
							</div>
						</div>
						<div class="lms-ui-tab-table-wrapper col-2">
							<div class="lms-ui-tab-table-column groups">
								{if $node.gcount}
									<img src="img/nodegroup.gif" alt=""
										class="lms-ui-hint-rollover"
										data-url="?m=nodeinfo&nodegroups=1&id={$node.id}">
								{else}
									-
								{/if}
							</div>
							<div class="lms-ui-tab-table-column network">
								<strong>
									{if !empty($node.vlanid) || strlen($node.netnotes)}
										{capture assign="hint_text"}{strip}
											<div class="network-popup">
												{if !empty($node.vlanid)}
													<div class="network-popup-row"">
														{icon name="vlan" class="fa-fw"}
														<strong>{$node.vlanid}</strong>
													</div>
												{/if}
												{if strlen($node.netnotes)}
													<div class="network-popup-row">
														{icon name="notes" class="fa-fw"}
														<table>
															<tr>
																<td class="fall superlight">
																	{nl2br($node.netnotes|escape)}
																</td>
															</tr>
														</table>
													</div>
												{/if}
											</div>
										{/strip}{/capture}
										{hint icon="info" class="lms-ui-ignore-target-url" text=$hint_text}
									{/if}
									<A href="?m=netinfo&id={$node.netid}">{$node.netname|truncate:"20":"&hellip;":true}</A>
									{if $node.network_pub}
										(<A href="?m=netinfo&id={$node.network_pub.id}">{$node.network_pub.name|truncate:"20":"&hellip;":true}</A>)
									{/if}
								</strong>
							</div>
						</div>
					</div>
				</div>

				<div class="lms-ui-tab-table-column buttons">
					{button type="link" href="?m=nodeset&id={$node.id}"
						icon="{if $node.access}connected{else}disconnected{/if}"
						tip="{if $node.access}Disconnect{else}Connect{/if}"}
					{button type="link" href="?m=nodewarn&id={$node.id}"
						icon="{if $node.warning}warnon{else}warnoff{/if}"
						tip="{if $node.warning}Disable notice{else}Enable notice{/if}"}
					<input type="hidden" value="{$node.name}">
					{button type="link" class="delete-node" href="?m=nodedel&id={$node.id}" icon="delete" tip="Delete"}
					{button type="link" href="?m=nodeadd&ownerid={$customerinfo.id}&premac[]={$node.mac|replace:",":"&premac[]="}&prename={t a=$node.name}$a_clone{/t}{if $node.address_id}&pre_address_id={$node.address_id}{/if}"
						icon="clone" tip="Clone"}
					{button type="link" href="?m=nodeedit&id={$node.id}" icon="edit" tip="Edit"}
					{button type="link" href="?m=nodeinfo&id={$node.id}" icon="view" tip="Info"}
					<INPUT type="checkbox" class="lms-ui-multi-check" name="marks[{$node.id}]" value="{$node.id}" form="custnodeslist-form">
				</div>
			</div>

			{foreachelse}
			<div class="lms-ui-tab-empty-table{if $customerinfo.deleted} red{/if}">
				{if $customerinfo.deleted}
					{trans("That customer has been deleted.")}
				{else}
					{trans("That customer hasn't got any node.")}
				{/if}
			</div>
			{/foreach}

		{/tab_table}

{if $customernodes}
		{tab_button_panel}
			{tab_buttons}
				<i class="lms-ui-icon-plug"></i>
				{button onclick="javascript:setstatus(1);" label="Connect"}
				{button onclick="javascript:setstatus(0);" label="Disconnect"}
				<i class="lms-ui-icon-warning"></i>
				{button onclick="javascript:setwarning(1);" label="Enable"}
				{button onclick="javascript:setwarning(0);" label="Disable"}
				{if $allnodegroups}
				<i class="lms-ui-icon-cg"></i>
				{button onclick="javascript:setgroup('setgroup');" label="Add"}
				{button onclick="javascript:setgroup('unsetgroup');" label="Remove"}
				<SELECT SIZE="1" id="groupselect">
					{foreach $allnodegroups as $nodegroup}
						<OPTION value="{$nodegroup.id}"{if $listdata.nodegroup == $nodegroup.id} selected{/if}>
							{$nodegroup.name|truncate:30:"&hellip;":true}
						</OPTION>
					{/foreach}
				</SELECT>
				{/if}
			{/tab_buttons}
			{tab_buttons}
				<label>
					{trans("Check All")}
					<INPUT TYPE="checkbox" class="lms-ui-multi-check-all" VALUE="1">
				</label>
			{/tab_buttons}
		{/tab_button_panel}
{/if}

	{/tab_contents}
{/tab_container}
