| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <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">
- <%= link_to debtors_path(:filter => @filter, :current_page => @current_page), {:class=>"btn blue-hoki pull-right margin-bottom-10"} do %> <i class="fa fa-angle-left "></i> Regresar
- <% end %>
- <!-- 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">Ventas al cliente <%= @custom.nick_name %></span>
- <span class="caption-helper"></span>
- </div>
- </div>
- <div class="portlet-body">
- <!-- tabs? -->
- <div class="tabbable-custom ">
- <ul class="nav nav-tabs ">
- <li class="active">
- <a href="#customer_sales" data-toggle="tab" aria-expanded="true"> Ventas </a>
- </li>
- <li class="">
- <a href="#abonos" data-toggle="tab" aria-expanded="false"> Abonos </a>
- </li>
- </ul>
- <div class="tab-content">
- <div class="tab-pane active" id="customer_sales">
- <div class="pull-right-margin-bottom-10">
- <!-- búsqueda por fecha-->
- <div class="row">
- <div class="col-md-11">
- <%= hidden_field_tag 'title_for_print' %>
- <div class="form-group">
- <%= label_tag :begin_date, "Fecha", {:class=>"col-md-1 control-label"} do %> Desde
- <% end %>
- <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
- <div class='input-group date' id='begin_date'>
- <input id="start" type='text' class="form-control"/>
- <span class="input-group-addon">
- <span class="glyphicon glyphicon-calendar"></span>
- </span>
- </div>
- </div>
- <%= label_tag :end_date, "Fecha", {:class=>"col-md-1 control-label"} do %> Hasta
- <% end %>
- <div class="col-sm-2" style="padding-left:0px;padding-right:0px;">
- <div class='input-group date' id='end_date'>
- <input id="end" type='text' class="form-control"/>
- <span class="input-group-addon">
- <span class="glyphicon glyphicon-calendar"></span>
- </span>
- </div>
- </div>
- <button class="btn btn-icon-only blue" style="margin-left:25px" onclick="salesByDate()">
- <i class="fa fa-search"></i>
- </button>
- </div>
- </div>
- </div>
- <!-- fin búsqueda por fecha-->
- <!-- contenido customer sales -->
- <table class="table table-striped table-bordered table-hover tableadvancedprintable" id="sales_table">
- <thead>
- <tr>
- <th>#</th>
- <th>Código de venta</th>
- <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
- <th>Punto de venta</th>
- <% end %>
- <th>Vendedor</th>
- <th>Fecha</th>
- <th>Tipo</th>
- <th>Productos</th>
- <th>Status</th>
- <th>Total</th>
- <th>Abonado</th>
- <th>Restante</th>
- <th width="15%">Acciones</th>
- </tr>
- </thead>
- <tbody id="customer_sales">
- <% @sales.each_with_index do |sale, key| %>
- <tr class=<%= (sale.cancelled? ? 'danger' : (sale.paid? ? 'success' : '')) %>>
- <td><%= sale.id %></td>
- <td><%= sale.sale_code %> </td>
- <% if current_user.usertype == "A" || current_user.usertype == "SS" %>
- <td> <%= sale.get_pointsale.name %> </td>
- <% end %>
- <td><%= sale.user.first_name %> </td>
- <td><%= l(sale.date_sale, :format => '%d/%m/%Y') %></td>
- <td>
- <% if sale.saletype == "credit" && sale.credit_note.blank? %>
- Crédito
- <% elsif sale.saletype == "credit" && sale.credit_note.present? %>
- Crédito/vale
- <% else %>
- Contado
- <% end %>
- </td>
- <td><%= sale.products.count %></td>
- <td><%= sale_status(sale) %></td>
- <td><%= number_to_currency(sale.total, precision: 2) %></td>
- <% credito = Credit.where(:sale_id => sale.id).first %>
- <% if credito.present? %>
- <% abonos = CreditPayment.where(:credit_id => credito.id, :status => 0).sum(:quantity) %>
- <% if abonos.present? %>
- <td><%= number_to_currency(abonos, precision: 2) %></td>
- <% end %>
- <td><%= number_to_currency(credito.rest, precision: 2) %></td>
- <% else %>
- <td></td>
- <td></td>
- <% end %>
- <td class="text-center">
- <%= link_to sale, {:class=>"btn btn-icon-only default", :title=>"Ver venta"} do %>
- <i class="fa fa-search"></i>
- <% end %>
- <% if can? :destroy, Sale %>
- <% daysToCancel = @pos_config.days_cancel_sale %>
- <% if (sale.date_sale + daysToCancel.days >= Date.today) && !sale.cancelled? %>
- <%= link_to sale , method: :delete, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar venta", data: { confirm: '¿Está seguro que desea cancelar la venta?' } do %> <i class="fa fa-ban"></i>
- <% end %>
- <% end %>
- <% end %>
- </td>
- </tr>
- <% end %>
- </tbody>
- </table>
- </div>
- </div>
- <!-- fin contenido customer sales -->
- <!-- contenido abono -->
- <div class="tab-pane" id="abonos">
- <table class="table table-striped table-bordered table-hover tableadvancedprintable" id="sales_table">
- <thead>
- <tr>
- <th>Folio</th>
- <th>Fecha</th>
- <th>Deuda</th>
- <th>Abono</th>
- <th>Restante</th>
- <td>Status</td>
- <th width="15%">Acciones</th>
- </tr>
- </thead>
- <tbody id="abonos">
- <% @credit.each_with_index do |credit, key| %>
- <% abonos = CreditPayment.where(:credit_id => credit.id).order('id') %>
- <% total = credit.total %>
- <% abonos.each_with_index do |abono, key| %>
- <% rest = total - abono.quantity %>
- <tr class=<%= (credit.cancelled? ? 'danger' : (credit.active? ? 'success' : '')) %>>
- <td><%= credit.sale.sale_code %> </td>
- <td><%= l(abono.date_payment, :format => '%d/%m/%Y') %></td>
- <td><%= number_to_currency(total, precision: 2) %></td>
- <td><%= number_to_currency(abono.quantity, precision: 2) %></td>
- <td><%= number_to_currency(rest, precision: 2) %></td>
- <td>
- <% case abono.status %>
- <% when "cancelled"%>
- <span class="label label-danger"> CANCELADO </span>
- <% when "active"%>
- <span class="label label-success"> ACTIVO </span>
- <% end %>
- </td>
- <td class="text-center">
- <% if !abono.cancelled? && abono.cash_registers_move.present? && abono.cash_registers_move.open_cash_register.open?%>
- <%= link_to cash_move_delete_payment_path(:credit_payment_id => abono.id, :credit => credit.id) , method: :delete_credit_payment, :class => "btn btn-icon-only btn-danger", :title=>"Cancelar abono", data: { confirm: '¿Está seguro que desea cancelar el abono?' } do %> <i class="fa fa-ban"></i>
- <% end %>
- <% end %>
- </td>
- <% total -= abono.quantity %>
- </tr>
- <% end %>
- <% end %>
- </tbody>
- </table>
- </div>
- <!-- fin contenido abono -->
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- END PAGE CONTENT INNER -->
- </div>
- </div>
- <!-- END PAGE CONTENT BODY -->
- <!-- END CONTENT BODY -->
- </div>
- <!-- END CONTENT -->
- </div>
- <script>
- $(document).on("page:change", function() {
- App.init();
- $('#begin_date').datetimepicker({
- icons: {
- date: "fa fa-calendar"
- },
- format: "DD/MM/YYYY",
- defaultDate: moment().startOf('month').toDate()
- });
- $('#end_date').datetimepicker({
- icons: {
- date: "fa fa-calendar"
- },
- format: "DD/MM/YYYY",
- defaultDate: moment().endOf('month').toDate()
- });
- var startDate = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY')
- var endDate = moment($("#end_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY');
- $('#title_for_print').val('Ventas del ' + startDate + ' al ' + endDate);
- });
- function salesByDate() {
- var start = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
- var end = moment($("#end_date").data("date"), "DD-MM-YYYY").format('YYYY-MM-DD HH:mm:ss');
- var cliente = '<%= @custom.id %>'
- App.blockUI({
- target: $("#sales_table"),
- animate: true
- });
- $.ajax({
- type: "get",
- url: '/find_customer_sales_by_date/' + start + '/' + end + '/' + cliente,
- dataType: 'script',
- success: function(data) {
- window.setTimeout(function() {
- App.unblockUI($("#sales_table"));
- var startDate = moment($("#begin_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY')
- var endDate = moment($("#end_date").data("date"), "DD-MM-YYYY").format('DD/MM/YYYY');
- $('#title_for_print').val('Ventas del ' + startDate + ' al ' + endDate);
- }, 100);
- }
- });
- }
- </script>
|