<!-- BEGIN CONTAINER -->
<div class="page-container">
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<!-- BEGIN CONTENT BODY -->
		<!-- BEGIN PAGE HEAD-->
		<div class="page-head hidden-print">
			<div class="container-fluid">
				<!-- BEGIN PAGE TITLE -->
				<div class="page-title">
					<h1>Detalle del corte de caja </h1>
				</div>
				<!-- END PAGE TITLE -->
			</div>
		</div>
		<!-- END PAGE HEAD-->
		<!-- BEGIN PAGE CONTENT BODY -->
		<div class="page-content">
			<div class="container-fluid">
				<div class="pull-right margin-bottom-10 ">
                    <a class="btn blue hidden-print" onclick="javascript:window.print();"> Imprimir
                        <i class="fa fa-print"></i>
                    </a>
					<%= link_to  cash_outs_path(:filter => @filter, :current_page => @current_page), {:class=>"fr-space btn blue-hoki hidden-print"} do %>
						<i class="fa fa-angle-left "></i>
						Regresar
					<% end %>
				</div>
				<!-- 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 margin-top-10">
					<div class="invoice">
						<div class="visible-print invoice-logo">
							<h1>Detalle del corte de caja</h1>
						</div>
						<div class="row">
							<!-- informacion de la venta -->
							<div class="col-md-4 col-sm-6">
								<div class="portlet light bordered">
									<div class="portlet-title">
										<div class="caption"> <i class="fa fa-info-circle"></i>Datos generales </div>
									</div>
									<div class="portlet-body">
										<!-- para el view -->
										<div class="hidden-print">
											<div class="row static-info">
												<div class="col-md-6 name"><i class="fa fa-calendar-o"></i>
												&nbsp&nbsp Fecha:</div>
												<div class="col-md-6 value"> <%= l(@cash_out.created_at, :format => '%A, %d de %B de %Y') %>  </div>
											</div>
											<% if current_user.usertype == "A" %>
												<div class="row static-info">
													<div class="col-md-6 name"><i class="fa fa-fw fa-cart-plus"></i> &nbsp Punto de venta:</div>
													<div class="col-md-6 value"> <%= OpenCashRegister.get_pointsale(@cash_out.open_cash_register_id, "open_cash_register").name %>  </div>
												</div>
											<% end %>
											<div class="row static-info">
												<div class="col-md-6 name"><i class="fa fa-fw fa-cart-plus"></i> &nbsp Caja registradora:</div>
												<div class="col-md-6 value"> <%= @cash_out.open_cash_register.cash_register.name %>  </div>
											</div>
											<div class="row static-info">
												<div class="col-md-6 name"><i class="fa fa-odnoklassniki"></i>
												&nbsp&nbsp Realizó:</div>
												<div class="col-md-6 value"> <%= @cash_out.user.first_name %>  </div>
											</div>
											<div class="row static-info">
												<div class="col-md-6 name"><i class="fa fa-odnoklassniki"></i>
												&nbsp&nbsp Recibió:</div>
												<div class="col-md-6 value"> <%= @cash_out.received_by.first_name %>  </div>
											</div>
											<div class="row static-info">
												<div class="col-md-6 name"><i class="fa fa-comments"></i>
												&nbsp&nbsp Observaciones:</div>
												<div class="col-md-10 value"> <%= @cash_out.observations %>  </div>
											</div>
										</div>

										<!-- para la vista de impresion -->
										<ul class="list-unstyled visible-print">
                                            <li>
                                                <i class="fa fa-calendar-o"></i>&nbsp Fecha:
                                                <strong><%= l(@cash_out.created_at, :format => '%A, %d de %B de %Y') %> </strong>
                                            </li>
                                            <% if current_user.usertype == "A" %>
	                                            <li>
	                                                <i class="fa fa-fw fa-cart-plus"></i>&nbsp Punto de venta:
	                                                <strong><%= OpenCashRegister.get_pointsale(@cash_out.open_cash_register_id, "open_cash_register").name %></strong>
	                                            </li>
                                            <% end %>
                                            <li>
                                                <i class="fa fa-fw fa-cart-plus"></i>&nbsp Caja registradora:
                                                <strong> <%= @cash_out.open_cash_register.cash_register.name %></strong>
                                            </li>
                                            <li>
                                                <i class="fa fa-odnoklassniki"></i>&nbsp Realizó:
                                                <strong> <%= @cash_out.user.first_name %> </strong>
                                            </li>
                                            <li>
                                                <i class="fa fa-odnoklassniki"></i>&nbsp Recibió:
                                                <strong> <%= @cash_out.received_by.first_name %> </strong>
                                            </li>
                                            <li>
                                                <i class="fa fa-odnoklassniki"></i>&nbsp Observaciones:
                                                <strong> <%= @cash_out.observations %> </strong>
                                            </li>
                                        </ul>
									</div>
								</div>
							</div>
							<div class="col-md-8 col-sm-6">
								<div class="portlet light bordered">
									<div class="portlet-title">
										<div class="caption"> <i class="fa fa-bars"></i>Resumen </div>
									</div>
									<div class="portlet-body">
										<div class="">
											<div class="row">
												<div class="col-md-4">
												    <div class="hidden-print" style="padding-left: 0px">
												      <ul class="list-group">
												        <li class="list-group-item list-group-item-default"> Total de ventas
												        <span class="pull-right label label-warning"><%= number_to_currency(@sales_total, precision: 2) %></span>
												        </li>
												      </ul>
												    </div>
												</div>
												<div class="col-md-4">
												    <div class="hidden-print" style="padding-left: 0px">
												      <ul class="list-group">
												        <li class="list-group-item list-group-item-default"> Total de egresos
												        <span class="pull-right label label-warning"><%= number_to_currency(@expenses_total, precision: 2) %></span>
												        </li>
												      </ul>
												    </div>
												</div>

												<div class="col-md-4">
												    <div class="hidden-print" style="padding-left: 0px">
												      <ul class="list-group">
												        <li class="list-group-item list-group-item-default"> Efectivo inicial
												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %></span>
												        </li>
												      </ul>
												    </div>
												</div>

												<div class="col-md-4">
												    <div class="hidden-print" style="padding-left: 0px">
												      <ul class="list-group">
												        <li class="list-group-item list-group-item-default"> Retiro
												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.received_cash, precision: 2) %></span>
												        </li>
												      </ul>
												    </div>
												</div>

												<div class="col-md-4">
												    <div class="hidden-print" style="padding-left: 0px">
												      <ul class="list-group">
												        <li class="list-group-item list-group-item-default"> Fondo
												        <span class="pull-right label label-warning"><%= number_to_currency(@cash_out.cash_fund, precision: 2) %></span>
												        </li>
												      </ul>
												    </div>
												</div>
											</div>
											<!-- saldo inicial de la caja para el view-->

											<!-- saldo inicial de la caja para el print view -->
											<ul class="list-unstyled visible-print">
	                                            <li>
	                                                <i class="fa fa-money"></i>&nbsp Total de ventas:
	                                                <strong><%= number_to_currency(@sales_total, precision: 2) %> </strong>
	                                            </li>
	                                            <li>
	                                                <i class="fa fa-money"></i>&nbsp Total de egresos:
	                                                <strong><%= number_to_currency(@expenses_total, precision: 2) %> </strong>
	                                            </li>
	                                            <li>
	                                                <i class="fa fa-money"></i>&nbsp Efectivo inicial:
	                                                <strong><%= number_to_currency(@cash_out.open_cash_register.initial_cash, precision: 2) %> </strong>
	                                            </li>
	                                            <li>
	                                                <i class="fa fa-money"></i>&nbsp Retiro de efectivo:
	                                                <strong><%= number_to_currency(@cash_out.received_cash, precision: 2) %> </strong>
	                                            </li>
	                                            <li>
	                                                <i class="fa fa-money"></i>&nbsp Fondo de caja:
	                                                <strong><%= number_to_currency(@cash_out.cash_fund, precision: 2) %> </strong>
	                                            </li>

											</ul>
									        <table class="table table-striped table-hover">
									            <thead>
									                <tr class="uppercase">
									                    <th> # </th>
									                    <th> Método de pago </th>
									                    <th> total de ingresos </th>
									                    <th> total de egresos </th>
									                    <th> Total </th>
									                </tr>
									            </thead>
									            <tbody>
									              <% @cash_out.cash_out_details.each_with_index do |detail, key| %>
									                <tr>
									                  <td> <%= key +1 %> </td>
									                  <td> <%= detail.payment_method.method %> </td>
									                  <td> <%= number_to_currency(detail.incoming, precision: 2) %> </td>
									                  <td> <%= number_to_currency(detail.outgoing, precision: 2) %> </td>
									                  <td>
									                    <%= number_to_currency(detail.total, precision: 2) %>
									                  </td>
									                </tr>
									              <% end %>
									            </tbody>
					                    	</table>
										</div>
			                    	</div>
								</div>
							</div>
							<div class="col-md-12 col-sm-12">
								<div class="portlet light bordered ">
									<div class="portlet-title">
										<div class="caption"> <i class="fa fa-arrow-right"></i>Entradas </div>
									</div>
									<div class="portlet-body">
										<table class="table table-striped table-hover">
											<thead>
										        <tr>
										          <th>#</th>
										          <th>Folio</th>
										          <th>Caja registradora</th>
										          <th>Método de pago</th>
										          <th>Cantidad</th>
										          <th>Concepto</th>
										          <th>Hora</th>
										        </tr>
											</thead>
											<tbody>
										        <% @incomings.each_with_index do |move, key| %>
										        <tr>
										          <td><%= key + 1 %></td>
										          <td>
										            <% case move.concept %>
          												<% when "sale",  "reserved_payment", "reserved_first_payment", "reserved_last_payment", "products_return" %>
										                <%= move.sale.sale_code %>
										              <% when "purchase"%>
										                <%= move.purchase.purchase_code %>
										              <% when "expense"%>
										                <%= move.expense.expense_code %>
										              <% when "credit_payment"%>
										                <%= move.credit_payment.id %>
										            <% end %>
										          </td>
										          <td><%= move.open_cash_register.cash_register.name%></td>
										          <td><%= move.payment_method.method %></td>
										          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
										          <td>
                                  <%= cash_move_type(move) %>
								           		 </td>
										          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
										        </tr>
										        <% end %>
											</tbody>
										</table>
									</div>
								</div>
							</div>
							<div class="col-md-12 col-sm-12">
								<div class="portlet light bordered ">
									<div class="portlet-title">
										<div class="caption"> <i class="fa fa-arrow-left"></i>Salidas </div>
									</div>
									<div class="portlet-body">
										<table class="table table-striped table-hover">
											<thead>
										        <tr>
										          <th>#</th>
										          <th>Folio</th>
										          <th>Caja registradora</th>
										          <th>Método de pago</th>
										          <th>Cantidad</th>
										          <th>Concepto</th>
										          <th>Hora</th>
										        </tr>
											</thead>
											<tbody>
										        <% @outgoings.each_with_index do |move, key| %>
										        <tr>
										          <td><%= key + 1 %></td>
										          <td>
										            <% case move.concept %>
										              <% when "sale",  "reserved_payment",  "credit_payment" %>
										                <%= move.sale.sale_code %>
										              <% when "purchase"%>
										                <%= move.purchase.purchase_code %>
										              <% when "expense"%>
										                <%= move.expense.expense_code %>
										            <% end %>
										          </td>
										          <td><%= move.open_cash_register.cash_register.name%></td>
										          <td><%= move.payment_method.method %></td>
										          <td><%= number_to_currency(move.quantity, precision: 2) %></td>
										          <td>
						                          	<% case move.concept %>
						                          	<% when "sale"%>
						                            	Venta cancelada
						                          	<% when "purchase"%>
						                            	Compra
						                          	<% when "expense"%>
										                <strong> <%= move.expense.expensesconcept.name %></strong> <br>
										                <%= move.expense.observations %>
							                          <% end %>
								           		 </td>
										          <td><%= l(move.created_at, :format => '%I:%M %p') %> </td>
										        </tr>
										        <% end %>
											</tbody>
										</table>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- END PAGE CONTENT INNER -->
			</div>
		</div>
		<!-- END PAGE CONTENT BODY -->
		<!-- END CONTENT BODY -->
	</div>
	<!-- END CONTENT -->
</div>
	<!-- END CONTAINER
