<template name="livechatCurrentChats">
	{{#requiresPermission 'view-livechat-manager'}}
		<fieldset>
			<form class="form-inline" method="post">
				<div class="form-group">
					<label for="name">{{_ "Name"}}</label>
					<input type="text" class="rc-input__element" name="name">
				</div>

				<div class="form-group">
					<label for="agent">{{_ "Served_By"}}</label>
					<select name="agent">
						<option value=""></option>
						{{#each agents}}
							<option value="{{_id}}">{{username}}</option>
						{{/each}}
					</select>
				</div>
				<div class="form-group">
					<label for="status">{{_ "Status"}}</label>
					<select name="status">
						<option value=""></option>
						<option value="opened">{{_ "Opened"}}</option>
						<option value="closed">{{_ "Closed"}}</option>
					</select>
				</div>
				<div class="form-group input-daterange">
					<span class="input-group-addon">{{_ "Date_From"}}</span>
					<input type="text" class="form-control rc-input__element" id="from" name="from" >
						<span class="input-group-addon">{{_ "Date_to"}}</span>
					<input type="text" class="form-control rc-input__element" id="to" name="to">
				</div>
				<button class="button">{{_ "Filter"}}</button>
			</form>
		</fieldset>
		<div class="list">
			<table>
				<thead>
					<tr>
						<th width="25%">{{_ "Name"}}</th>
						<th width="25%">{{_ "Served_By"}}</th>
						<th width="15%">{{_ "Started_At"}}</th>
						<th width="15%">{{_ "Last_Message_At"}}</th>
						<th width="20%">{{_ "Status"}}</th>
						<th>&nbsp;</th>
					</tr>
				</thead>
				<tbody>
					{{#each livechatRoom}}
						<tr class="row-link">
							<td>{{fname}}</td>
							<td>{{servedBy}}</td>
							<td>{{startedAt}}</td>
							<td>{{lastMessage}}</td>
							<td>{{status}}</td>
							{{#requiresPermission 'remove-closed-livechat-rooms'}}
								{{#if isClosed}}
									<td><a href="#remove" class="remove-livechat-room"><i class="icon-trash"></i></a></td>
								{{else}}
									<td>&nbsp;</td>	
								{{/if}}	
							{{else}}						
								<td>&nbsp;</td>
							{{/requiresPermission}}									
						</tr>
					{{/each}}
				</tbody>
			</table>
		</div>
		<div class="text-center">
			<button class="button load-more">{{_ "Load_more"}}</button>
		</div>
	{{/requiresPermission}}
</template>
