
<div class="white_container">
		
		<h2 style="margin-bottom:20px; float:left;"><i class="fa fa-list"></i><span> <?php echo Lang::get('category.categories'); ?></span></h2>
		<div class="btn btn-color" style="margin-left:20px;" data-toggle="modal" data-target="#new-category"><span class="fa fa-plus"></span> New Category</div>
		<div class="table-responsive">
			<table class="table table-condensed">
				<tr>
					<th><?php echo Lang::get('category.category'); ?></th>
					<th><?php echo Lang::get('category.category_total'); ?></th>
					<th><?php echo Lang::get('common.order'); ?></th>
					<th><?php echo Lang::get('common.actions'); ?></th>
					<?php foreach($categories as $category): ?>

							<tr>
								<td>
									<?php echo $category->name; ?>
								</td>
								<td>
									<?php echo $category->totalMedia(); ?>
								</td>
								<td>
									<?php echo $category->order; ?>
								</td>
								<td style="width:190px;">
									<a href="#" data-toggle="modal" data-target="#edit-<?php echo $category->id; ?>" class="btn btn-xs btn-primary edit-media" style="margin-right:10px;"><span class="fa fa-edit"></span> <?php echo Lang::get('common.edit'); ?></a>
									<?php if($category->id != 1): ?>
										<a href="<?php echo URL::to('category/delete') . '/' . $category->id; ?>" class="btn btn-xs btn-danger"><span class="fa fa-trash-o"></span> <?php echo Lang::get('common.delete'); ?></a>
									<?php endif; ?>
								</td>
								
							</tr>
							
					<?php endforeach; ?>
			</table>
		</div>
		
	</div>



	<!-- Create Category Modal -->
	<div class="modal fade" id="new-category" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel"><?php echo Lang::get('category.category_new'); ?></h4>
			</div>
		    <div class="modal-body">
		      
		      	<form method="POST" action="<?php echo URL::to('categories'); ?>" accept-charset="UTF-8">
				<p><input name="name" type="text" class="form-control" id="name" placeholder="name"></p>
				<p><input name="order" type="text" class="form-control" id="order" placeholder="order"></p>
		      	
			</div><!-- .modal-body -->
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo Lang::get('common.cancel'); ?></button>
				<input type="submit" class="btn btn-color" value="Add Category" />
			</div>
				</form>

	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
	<!-- END Create Category Modal -->

	<?php foreach($categories as $category): ?>
	<!-- Modal -->
	<div class="modal fade" id="edit-<?php echo $category->id; ?>" data-id="<?php echo $category->id; ?>" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
	    <div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel"><?php echo Lang::get('common.editing'); ?> <?php echo $category->name; ?></h4>
			</div>
		    <div class="modal-body">
		      
		      	<form method="POST" action="<?php echo URL::to('categories/update') . '/' . $category->id; ?>" accept-charset="UTF-8">
					<ul>
				        <li>
				        	<label for="name"><?php echo Lang::get('common.name'); ?></label>
		           			<input type="text" <?php if($category->id != 1): ?> readonly="readonly" <?php endif; ?> class="form-control" name="name" id="name" value="<?php echo $category->name; ?>" />
				        </li>

				        <li>
				        	<label for="order"><?php echo Lang::get('common.order'); ?></label>
		           			<input type="number" class="form-control" name="order" id="order" value="<?php echo $category->order; ?>" />
				        </li>
					</ul>
			</div><!-- .modal-body -->
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo Lang::get('common.cancel'); ?></button>
				<input type="submit" class="btn btn-color" value="Update Category" />
			</div>
			</form>

	    </div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->



	<?php endforeach; ?>
