		<!-- BEGIN CONTAINER -->
		<div class="page-container">
			<!-- BEGIN CONTENT -->
			<div class="page-content-wrapper">
				<!-- BEGIN CONTENT BODY -->
				<!-- BEGIN PAGE HEAD-->
				<div class="page-head">
					<div class="container-fluid">
						<!-- BEGIN PAGE TITLE -->
						<div class="page-title">
							<h1>Clientes deudores</h1>
						</div>
						<!-- END PAGE TITLE -->
					</div>
				</div>
				<!-- END PAGE HEAD-->
				<!-- BEGIN PAGE CONTENT BODY -->
				<div class="page-content">
					<div class="container-fluid">
						<!-- BEGIN PAGE BREADCRUMBS -->
						<ul class="page-breadcrumb breadcrumb">
							<%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
						</ul>
						<!-- END PAGE BREADCRUMBS -->
						<!-- BEGIN PAGE CONTENT INNER -->
						<div class="page-content-inner">
							<div id="notice">
							<% if success %>
								<div class="alert alert-success">
									<p><%= success %></p>
								</div>
							<% elsif warning %>
								<div class="alert alert-warning">
									<p><%= warning %></p>
								</div>
							<% end %>
							</div>
							<div class="row">
								<div class="col-md-12">
									<div class="portlet light ">
										<div class="portlet-title">
											<div class="caption">
												<i class="fa fa-list "></i>
												<span class="caption-subject bold uppercase">Lista de clientes con ventas a crédito</span>
											</div>
										</div>
										<div class="portlet-body">
											<input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
											<input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
											<table class="table table-striped table-bordered table-hover tableadvanced">
												<thead>
													<tr>
														<th>Cliente</th>
														<th>Límite de crédito</th>
														<th>Monto a pagar</th>
														<th>Fecha de última venta</th>
														<th>Fecha de último abono</th>
														<th>Status</th>
														<th width="15%">Acciones</th>
													</tr>
												</thead>
												<tbody>
													<% @customers.each_with_index do |customer, key| %>
													<% customer.verify_credit %>
													<% payment = CreditPayment.where(:customer_id => customer.id, :status => 0).order("date_payment DESC").first %>
													<% credito = Credit.activos.where(:customer_id => customer.id).sum(:rest) %>
													<% sales = Sale.where("customer_id = #{customer.id} and status != 1 and status != 2 and saletype = 0").order("date_sale DESC") %>
													<% if sales.first.present? && sales.first.status != "2" && credito > 0 %>
													<tr>
														<td><%= customer.nick_name %> </td>
														<% if customer.status != "debtor" %>
															<td><span class="label label-sm label-success"> <i class="fa fa-check"></i> Crédito </span> <br> $ <%= customer.credit_limit %></td>

														<% else %>
															<td><span class="label label-sm label-danger"> <i class="fa fa-times"></i> Crédito expirado </span></td>

														<% end %>
														<td><%= number_to_currency(credito, precision: 2) %></td>
														<td><%= l(sales.first.date_sale, :format => '%d/%m/%Y')  %></td>
														<td>
														<% if payment.present? %>
															<%= l(payment.date_payment, :format => '%d/%m/%Y')  %>
														<% end %>
														</td>
														<td>
															<% if customer.status == "inactive" %>
																<i class='fa fa-times fa-2 font-red'></i>
															<% else %>
																<i class='fa fa-check fa-2 font-green'></i>
															<% end %>
														</td>
														<td>
															<%= link_to customer_sales_path(:customer_id => customer.id), {:class=>"btn btn-icon-only default filtros2", :title=>"Ver detalles de ventas"} do %>
																<i class="fa fa-search"></i>
															<% end %>

															<%= link_to new_cash_registers_move_path(:sale => sales.last.id, :customer => customer.id, format: 'js'), remote: true, data: { toggle: "modal", target: "#new" }, :class=>"btn btn-icon-only green-dark", :title=>"Abonar" do %><i class="fa fa-dollar"></i>
															<% end %>
														</td>
													</tr>
													<% end %>
													<% end %>
												</tbody>
											</table>
										</div>
									</div>
								</div>
							</div>
						</div>
						<!-- END PAGE CONTENT INNER -->
					</div>
				</div>
				<!-- END PAGE CONTENT BODY -->
				<!-- END CONTENT BODY -->
			</div>
			<!-- END CONTENT -->
		</div>
		<!-- END CONTAINER -->
