edti dashboard
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
class BatchesController < ApplicationController
|
||||
def index
|
||||
@batches=Batch.all.page(params[:page]).per(2)
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').order('batches.id desc').page(params[:page])
|
||||
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,14 @@ class HomeController < ApplicationController
|
||||
redirect_to new_member_session_path
|
||||
end
|
||||
def dashboard
|
||||
today= Date.today.strftime("%Y-%m-%d")
|
||||
@users=User.all
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.where("to_char(batches.created_at,'YYYY-mm-dd')=?",today)
|
||||
.select('batches.*,users.name as user_name').order('batches.id desc')
|
||||
|
||||
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id').select('batch_line_items.*,batches.order_ref as batch_name')
|
||||
.where("to_char(batches.created_at,'YYYY-mm-dd')=?",today)
|
||||
.page(params[:page]).per(5)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,8 +43,7 @@ class BatchLineItem < ApplicationRecord
|
||||
def self.to_csv(user_id)
|
||||
encrypt_key=""
|
||||
|
||||
find_user=User.find_by_id(user_id)
|
||||
|
||||
find_user=User.find_by_id(user_id)
|
||||
if !find_user.nil?
|
||||
encrypt_key=find_user.secrect_key
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order Ref</th>
|
||||
<th>Created By</th>
|
||||
<th>Created By</th>
|
||||
<th>Qty Processing</th>
|
||||
<th>Qty Success</th>
|
||||
<th>Qty Fail</th>
|
||||
@@ -26,7 +26,7 @@
|
||||
<% @batches.each do |batch| %>
|
||||
<tr>
|
||||
<td><%= batch.order_ref rescue '' %></td>
|
||||
<td><%= batch.created_by rescue '' %></td>
|
||||
<td><%= batch.user_name rescue '' %></td>
|
||||
<td><%= batch.qty_processing rescue '' %></td>
|
||||
<td><%= batch.qty_success rescue '' %></td>
|
||||
<td><%= batch.qty_fail rescue '' %></td>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="card-header">
|
||||
<strong>User List</strong>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
@@ -30,5 +30,81 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header"><strong>Latest Batch</strong> </div>
|
||||
<div class="card-block">
|
||||
<% if @batches.empty? %>
|
||||
<p class="center"> <strong>There is no batch created for today.</strong></p>
|
||||
<% else %>
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Order Ref</th>
|
||||
<th>Created By</th>
|
||||
<th>Qty Processing</th>
|
||||
<th>Qty Success</th>
|
||||
<th>Qty Fail</th>
|
||||
<th>Export Count</th>
|
||||
<th>Creatd At</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batches.each do |batch| %>
|
||||
<tr>
|
||||
<td><%= batch.order_ref rescue '' %></td>
|
||||
<td><%= batch.user_name rescue '' %></td>
|
||||
<td><%= batch.qty_processing rescue '' %></td>
|
||||
<td><%= batch.qty_success rescue '' %></td>
|
||||
<td><%= batch.qty_fail rescue '' %></td>
|
||||
<td><%= batch.export_count %></td>
|
||||
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="card">
|
||||
<div class="card-header"><strong>Latest Batch Line Item</strong> </div>
|
||||
<div class="card-block">
|
||||
<% if @batchLineItems.empty? %>
|
||||
<p class="center"> <strong>There is no batch line item for today.</strong></p>
|
||||
<% else %>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Serail No</th>
|
||||
<th>Wristband Code</th>
|
||||
<th>Manufacture UID</th>
|
||||
<th>Batch No</th>
|
||||
<th>Card Type</th>
|
||||
<th>Created At </th>
|
||||
<th>Update At </th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @batchLineItems.each do |item| %>
|
||||
<tr>
|
||||
<td><%= item.serial_no rescue '' %></td>
|
||||
<td><%= item.wristband_code rescue '' %></td>
|
||||
<td><%= item.manufacture_uid rescue '' %></td>
|
||||
<td><%= item.batch_name rescue '' %></td>
|
||||
<td><%= item.card_type rescue '' %></td>
|
||||
<td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<%=paginate @batchLineItems %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -39,8 +39,8 @@
|
||||
<td><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td>
|
||||
<%= link_to 'Detail',
|
||||
user_path(user), :class => 'btn btn-primary btn-sm ' %>
|
||||
<%= link_to t('.edit', :default => t("helpers.links.edit")),
|
||||
user_path(user), :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to 'Edit',
|
||||
edit_user_path(user), :class => 'btn btn-primary btn-sm' %>
|
||||
<%= link_to 'Delete', user_path(user), method: :delete, data: { confirm: 'Are you sure?' },:class => 'btn btn-primary btn-sm' %>
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user