<?php TPL::output('admin/global/header.tpl.htm'); ?>

<!--left-->
<?php TPL::output('admin/global/left.tpl.htm'); ?>
<!--left-->

<!-- main -->
<div id="main-content">
	<div class="clear"></div>
	<div class="content-box">
		<div class="content-box-header">
			<h3>Task management</h3>
			<ul class="content-box-tabs">
				<li><a href="#tab1" class="default-tab current">Task list</a></li>
				<li><a href="#tab2" class="">Create a new task</a></li>
			</ul>
			<div class="clear"></div>
		</div>
		<div class="content-box-content">
			<div class="tab-content default-tab" id="tab1">				
				<?php if ($this->tasks_list) { ?>
				<table class="list">
					<thead>
						<tr>
							<th width="50%">Task name</th>
							<th>Number of users</th>
							<th>Numbers sent</th>
							<th>Numbers read</th>
							<th>Created time</th>
							<th>Operation</th>
						</tr>
					</thead>
					<tbody style="border-bottom: 1px solid #ddd;">
						<?php foreach ($this->tasks_list AS $key => $val) { ?>
						<tr>
							<td><?php echo $val['title']; ?></td>
							<td><?php echo $val['users']; ?></td>
							<td><?php echo $val['sent']; ?></td>
							<td><?php echo $val['views']; ?></td>
							<td><?php echo date_friendly($val['time']); ?></a>
							<td><a href="account/edm/mail/<?php echo $val['id']; ?>" target="_blank">Email content</a> | <a href="admin/edm/export_active_users/<?php echo $val['id']; ?>">Export active user</a> | <a href="admin/edm/remove_task/<?php echo $val['id']; ?>" onclick="if (confirm('Confirm to delete the task?')) { window.location = this.href; } return false;">Delete</a></td>
						</tr>
						<?php } ?>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="6">
								<div class="pagination"><?php echo $this->pagination; ?></div>
								<div class="clear"></div>
							</td>
						</tr>
					</tfoot>
				</table>
				<?php } ?>
			</div>
			
			<div class="tab-content" id="tab2" style="display:none;">
				<form action="admin/edm/add_task/" method="post">
				
				<fieldset>
				<p>
					<label>Task title</label>
						<input class="text-input medium-input" type="text" name="title" />
				</p>
				
				<p>
					<label>Email title</label>
						<input class="text-input medium-input" type="text" name="subject" />
				</p>
				
				<p>
					<label>Sender name</label>
						<input class="text-input medium-input" type="text" name="from_name" value="<?php echo get_setting('site_name'); ?>" />
				</p>
				
				<p>
					<label>Usergroup</label>              
					<select name="usergroup_id" class="small-input">
						<option value="0"> - Select - </option>
						<?php foreach ($this->usergroups AS $key => $item) { ?>
						<option value="<?php echo $item['id']; ?>"<?php if ($_GET['usergroup_id'] == $item['id']) { ?> selected="selected"<?php } ?>><?php echo $item['title']; ?></option>
						<?php } ?>
					</select> 
				</p>
				
				<p>
					<label>Email content</label>
					<small>Please paste HTML code directly</small><br />
					<textarea class="text-input textarea" name="message" cols="79" rows="15"></textarea>
				</p>
				
				<p>
					<input class="button" type="submit" value="Create" />
				</p>
					
				</fieldset>
				
				<div class="clear"></div><!-- End .clear -->
				
			</form>
				
			</div>
			
		</div>
		<div class="clear"></div>
	</div>

<!-- footer -->
<?php TPL::output('admin/global/footer.tpl.htm'); ?>
<!-- footer -->

</div>
<!-- main -->

</div>

</body>
</html>