<ol class="breadcrumb">
	<li><a href="#/">Dashboard</a></li>
	<li class="active">Products</li>
</ol>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-midnightblue">
				<div class="panel-heading">
					<h2>Products</h2>
					<div class="panel-ctrls">
						<a class="button-icon" ng-click="vm._downloadCSV()" title="Download CSV"><i class="ti ti-save"></i></a>
						<a class="button-icon" href="#/products-import" title="Import From Quickbooks"><i class="ti ti-import"></i></a>
						<a class="button-icon" ng-click="vm._reload()" title="Reload"><i class="ti ti-reload"></i></a>
						<a href="#/products-reports" class="button-icon" title="View Reports"><i class="ti ti-bar-chart"></i></a>
						<a href="#/products/new" class="button-icon" title="New Product"><i class="ti ti-plus"></i></a>
					</div>
				</div>
				<div class="panel-body">
					<div class="row" style="margin-bottom: 15px;">
						<div class="col-md-9">
							<input type="text" class="form-control" ng-model="searchInput" placeholder="Search here...">
						</div>
						<div class="col-md-3">
							<select class="form-control" ng-model="vm.quickbooks_filter">
								<option value="">-- Quickbooks --</option>
								<option value="Yes">Yes</option>
								<option value="No">No</option>
								<option value="-1">All</option>
							</select>
						</div>
					</div>
					<table class="table table-striped">
						<thead>
							<tr>
								<th>Name</th>
								<th class="hidden-xs">Category</th>
								<th class="hidden-xs">SKU</th>
								<th class="hidden-xs">Base Price</th>
								<th class="hidden-xs">Cost Price</th>
								<th class="hidden-xs">Quickbooks</th>
								<th width="15%">Actions</th>
							</tr>
						</thead>
						<tbody>
							<tr dir-paginate="product in vm.products | filter: searchInput | filter: vm._filterByQuickbooks | itemsPerPage: 10">
								<td>
									<a href="#/products/{{product.id}}">
										{{product.name}}
									</a>
								</td>
								<td class="hidden-xs">
									<a href="#/product-categories/{{product.product_category.id}}">
										{{product.product_category.name}}
									</a>
								</td>
								<td class="hidden-xs">{{product.sku}}</td>
								<td class="hidden-xs">{{product.price | currency: "$"}}</td>
								<td class="hidden-xs">{{product.cost | currency: "$"}}</td>
								<td class="hidden-xs">
									<span ng-if="product.quickbooks_id">Yes</span>
									<span ng-if="!product.quickbooks_id">No</span>
								</td>
								<td>
									<div class="btn-group">
										<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
											<i class="ti ti-settings"></i>&nbsp;&nbsp;<span class="caret"></span>
										</button>
										<ul class="dropdown-menu" role="menu">
											<li><a href="#/products/{{product.id}}/edit">Edit</a></li>
											<li><a ng-click="vm._destroy(product.id)">Delete</a></li>
											<li class="divider"></li>
											<li>
												<a ng-click="vm._sendToQuickbooks(product.id)">
													<span ng-if="product.quickbooks_id">Update To Quickbooks</span>
													<span ng-if="!product.quickbooks_id">Add To Quickbooks</span>
												</a>
											</li>
										</ul>
									</div>
								</td>
							</tr>
						</tbody>
					</table>
					<p class="text-center" ng-show="vm.products.length == 0">No records found</p>
					<div class="row">
						<div class="col-sm-12 text-center">
							<dir-pagination-controls></dir-pagination-controls>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
