added purchases ffrontend
This commit is contained in:
parent
f7737ef653
commit
2e87baa4dd
File diff suppressed because it is too large
Load Diff
|
@ -73,32 +73,32 @@
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* line 92, ../sass/rwd.scss */
|
/* line 93, ../sass/rwd.scss */
|
||||||
.cp-main .cp-content .cp-submenu-box .cp-filter-box {
|
.cp-main .cp-content .cp-filter-box {
|
||||||
clear: both;
|
clear: both;
|
||||||
float: none;
|
float: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0 0 10px;
|
margin: 0 0 10px;
|
||||||
}
|
}
|
||||||
/* line 97, ../sass/rwd.scss */
|
/* line 98, ../sass/rwd.scss */
|
||||||
.cp-main .cp-content .cp-submenu-box .cp-filter-box select.form-control {
|
.cp-main .cp-content .cp-filter-box .form-control {
|
||||||
float: none;
|
float: none;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0 0 10px;
|
margin: 0 0 10px;
|
||||||
}
|
}
|
||||||
/* line 102, ../sass/rwd.scss */
|
/* line 103, ../sass/rwd.scss */
|
||||||
.cp-main .cp-content .cp-submenu-box .cp-filter-box .btn {
|
.cp-main .cp-content .cp-filter-box .btn {
|
||||||
float: left;
|
float: left;
|
||||||
margin: 0 10px 10px 0;
|
margin: 0 10px 10px 0;
|
||||||
}
|
}
|
||||||
/* line 106, ../sass/rwd.scss */
|
/* line 107, ../sass/rwd.scss */
|
||||||
.cp-main .cp-content .cp-submenu-box .cp-filter-box .btn-gray {
|
.cp-main .cp-content .cp-filter-box .btn-gray {
|
||||||
color: #333;
|
color: #333;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
border-color: #ccc;
|
border-color: #ccc;
|
||||||
}
|
}
|
||||||
/* line 110, ../sass/rwd.scss */
|
/* line 111, ../sass/rwd.scss */
|
||||||
.cp-main .cp-content .cp-submenu-box .cp-filter-box .btn-gray:hover {
|
.cp-main .cp-content .cp-filter-box .btn-gray:hover {
|
||||||
background: #ddd;
|
background: #ddd;
|
||||||
}
|
}
|
||||||
/* line 116, ../sass/rwd.scss */
|
/* line 116, ../sass/rwd.scss */
|
||||||
|
|
|
@ -232,6 +232,26 @@ class ClientManagementsController < CPanelController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def purchases
|
||||||
|
if !params[:query].present?
|
||||||
|
site_requests = SiteRequest.any_of({:site_id.in => current_cpanel_user.registered_site_ids.collect{|id| id.to_s}, :request_contract.ne => nil},{:c_panel_user_id => current_cpanel_user.id, :request_contract.ne => nil}).asc(:created_at)
|
||||||
|
@purchases = site_requests.collect{|sr| sr.request_contract.contract_purchase if sr.request_contract.contract_purchase != nil}
|
||||||
|
@purchases.delete(nil)
|
||||||
|
@purchases = Kaminari.paginate_array(@purchases).page(params[:page]).per(15)
|
||||||
|
else
|
||||||
|
site_requests = SiteRequest.where(:site_id => params[:query], :request_contract.ne => nil).asc(:created_at)
|
||||||
|
@purchases = site_requests.collect{|sr| sr.request_contract.contract_purchase if sr.request_contract.contract_purchase != nil}
|
||||||
|
@purchases.delete(nil)
|
||||||
|
@purchases = Kaminari.paginate_array(@purchases).page(params[:page]).per(15)
|
||||||
|
end
|
||||||
|
if request.xhr?
|
||||||
|
render :partial => "purchase_partial"
|
||||||
|
else
|
||||||
|
@user_sites = current_cpanel_user.registered_sites.collect{|rs|[rs.title, rs.id.to_s]}
|
||||||
|
@user_sites << ["New site request", "newsite"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def confirm_contract
|
def confirm_contract
|
||||||
contract = RequestContract.where(:uid => params[:contract_uid]).first rescue nil
|
contract = RequestContract.where(:uid => params[:contract_uid]).first rescue nil
|
||||||
contract.confirmed = true
|
contract.confirmed = true
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
<% @purchases.each do |purchase| %>
|
||||||
|
<% contract = purchase.request_contract %>
|
||||||
|
<div class="item-history">
|
||||||
|
<span class="site-title-history"><a href="" onclick="return false;">Purchase for contract : <%= contract.uid %></a></span>
|
||||||
|
<div class="info-site">
|
||||||
|
<span class="url-site"><i class="fa fa-money" aria-hidden="true"></i>Total : <%= purchase.total_amount %> NTD.</span>
|
||||||
|
<span class="url-site"><i class="fa fa-money" aria-hidden="true"></i>Amount Received : <span style="color:green;"> <%= purchase.total_amount_recieved %></span> NTD.</span>
|
||||||
|
<span class="time-site"><i class="fa fa-clock-o" aria-hidden="true"></i>Time : <%= purchase.created_at.strftime("%d %B, %Y %H:%M") %></span>
|
||||||
|
</div>
|
||||||
|
<% if !purchase.purchase_receipts.blank? %>
|
||||||
|
<div class="receipt-site">
|
||||||
|
<% purchase.purchase_receipts.each do |receipt| %>
|
||||||
|
<div class="item-receipt">
|
||||||
|
<table class="table-receipt" cellspacing="5">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>Receipt Number</th>
|
||||||
|
<th>Total Amount</th>
|
||||||
|
<th>Amount Received</th>
|
||||||
|
<th>Amount Pending</th>
|
||||||
|
<th>Receipt Status</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="number"><%= receipt.receipt_number %></td>
|
||||||
|
<td class="total"><%= receipt.amount %></td>
|
||||||
|
<td class="received"><%= receipt.amount_received %></td>
|
||||||
|
<td class="pending"><%= receipt.amount_pending %></td>
|
||||||
|
<td class="status">
|
||||||
|
<% if receipt.is_pending? %>
|
||||||
|
<span class="pending">Pending</span>
|
||||||
|
<% else %>
|
||||||
|
<span class="cleared">Cleared</span>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% if purchase.cleared? %>
|
||||||
|
<span class="status-detail pending">Cleared</span>
|
||||||
|
<% else %>
|
||||||
|
<span class="status-detail purchased">Pending</span>
|
||||||
|
<% end %>
|
||||||
|
<% if !purchase.purchase_receipts.blank? %>
|
||||||
|
<span class="action-site">
|
||||||
|
<a href="#" class="btn btn-receipt">Receipts</a>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -14,16 +14,16 @@
|
||||||
<div class="cp-submenu-box">
|
<div class="cp-submenu-box">
|
||||||
<a href="<%= cpanel_myhistory_path %>" class="submenu-item">Requests</a>
|
<a href="<%= cpanel_myhistory_path %>" class="submenu-item">Requests</a>
|
||||||
<a href="<%= cpanel_mycontracts_path %>" class="submenu-item active">Contracts</a>
|
<a href="<%= cpanel_mycontracts_path %>" class="submenu-item active">Contracts</a>
|
||||||
<a href="#" class="submenu-item">Purchases</a>
|
<a href="<%= cpanel_mypurchases_path %>" class="submenu-item">Purchases</a>
|
||||||
<div class="cp-filter-box">
|
</div>
|
||||||
<form action="" method="get">
|
<div class="cp-filter-box clear">
|
||||||
<%= select_tag "q", options_for_select(@user_sites, params[:q]), :prompt => "All", :class => "form-control" %>
|
<form action="" method="get">
|
||||||
<input type="submit" value="Filter" class="btn btn-success">
|
<%= select_tag "q", options_for_select(@user_sites, params[:q]), :prompt => "All", :class => "form-control" %>
|
||||||
<% if params[:q].present? %>
|
<input type="submit" value="Filter" class="btn btn-success">
|
||||||
<a href="/cpanel/contracts" class="btn btn-gray">Clear</a>
|
<% if params[:q].present? %>
|
||||||
<% end %>
|
<a href="/cpanel/contracts" class="btn btn-gray">Clear</a>
|
||||||
</form>
|
<% end %>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="cp-addsite-history">
|
<div class="cp-addsite-history">
|
||||||
<div class="box-request-history">
|
<div class="box-request-history">
|
||||||
|
|
|
@ -14,16 +14,16 @@
|
||||||
<div class="cp-submenu-box">
|
<div class="cp-submenu-box">
|
||||||
<a href="<%= cpanel_myhistory_path %>" class="submenu-item active">Requests</a>
|
<a href="<%= cpanel_myhistory_path %>" class="submenu-item active">Requests</a>
|
||||||
<a href="<%= cpanel_mycontracts_path %>" class="submenu-item">Contracts</a>
|
<a href="<%= cpanel_mycontracts_path %>" class="submenu-item">Contracts</a>
|
||||||
<a href="#" class="submenu-item">Purchases</a>
|
<a href="<%= cpanel_mypurchases_path %>" class="submenu-item">Purchases</a>
|
||||||
<div class="cp-filter-box">
|
</div>
|
||||||
<form action="" method="get">
|
<div class="cp-filter-box clear">
|
||||||
<%= select_tag "q", options_for_select(@user_sites, params[:q]), :prompt => "All", :class => "form-control" %>
|
<form action="" method="get">
|
||||||
<input type="submit" value="Filter" class="btn btn-success">
|
<%= select_tag "q", options_for_select(@user_sites, params[:q]), :prompt => "All", :class => "form-control" %>
|
||||||
<% if params[:q].present? %>
|
<input type="submit" value="Filter" class="btn btn-success">
|
||||||
<a href="/cpanel/history" class="btn btn-gray">Clear</a>
|
<% if params[:q].present? %>
|
||||||
<% end %>
|
<a href="/cpanel/history" class="btn btn-gray">Clear</a>
|
||||||
</form>
|
<% end %>
|
||||||
</div>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="cp-addsite-history">
|
<div class="cp-addsite-history">
|
||||||
<div class="box-request-history">
|
<div class="box-request-history">
|
||||||
|
|
|
@ -0,0 +1,94 @@
|
||||||
|
<% content_for :page_menu do %>
|
||||||
|
<ul class="list-sidebar">
|
||||||
|
<li class="item-sidebar"><a class="btn-sidebar" href="/cpanel/sites"><i class="fa fa-home" aria-hidden="true"></i><%= t("client_management.my_sites") %></a></li>
|
||||||
|
<li class="item-sidebar"><a class="btn-sidebar" href="<%= cpanel_myprofile_path %>"><i class="fa fa-address-card" aria-hidden="true"></i><%= t("client_management.profile") %></a></li>
|
||||||
|
<li class="item-sidebar active"><a class="btn-sidebar" href="<%= cpanel_myhistory_path %>"><i class="fa fa-history" aria-hidden="true"></i><%= t("client_management.history") %></a></li>
|
||||||
|
<li class="item-sidebar"><a class="btn-sidebar" href="#"><i class="fa fa-question-circle-o" aria-hidden="true"></i><%= t("client_management.help_and_faq") %></a></li>
|
||||||
|
<li class="item-sidebar"><a class="btn-sidebar" href="#"><i class="fa fa-user-circle-o" aria-hidden="true"></i><%= t("client_management.get_in_contact") %></a></li>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
<section class="cp-content col-md-10">
|
||||||
|
<h2 class="cp-page-title">
|
||||||
|
History
|
||||||
|
</h2>
|
||||||
|
<div class="cp-submenu-box">
|
||||||
|
<a href="<%= cpanel_myhistory_path %>" class="submenu-item">Requests</a>
|
||||||
|
<a href="<%= cpanel_mycontracts_path %>" class="submenu-item">Contracts</a>
|
||||||
|
<a href="<%= cpanel_mypurchases_path %>" class="submenu-item active">Purchases</a>
|
||||||
|
</div>
|
||||||
|
<div class="cp-filter-box clear">
|
||||||
|
<form action="" method="get">
|
||||||
|
<%= select_tag "q", options_for_select(@user_sites, params[:q]), :prompt => "All", :class => "form-control" %>
|
||||||
|
<input type="submit" value="Filter" class="btn btn-success">
|
||||||
|
<% if params[:q].present? %>
|
||||||
|
<a href="/cpanel/purchases" class="btn btn-gray">Clear</a>
|
||||||
|
<% end %>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="cp-addsite-history">
|
||||||
|
<div class="box-request-history">
|
||||||
|
<h3 class="sub-title">Purchases</h3>
|
||||||
|
<div id="history-loading" class="cp-loading-box" style="display: none;">
|
||||||
|
<span class="loading-text">
|
||||||
|
<%= t("client_management.loading_purchases") %>
|
||||||
|
</span>
|
||||||
|
<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i>
|
||||||
|
</div>
|
||||||
|
<div id="error-msg-area" class="cp-message-box hide">
|
||||||
|
<div class="message-text">
|
||||||
|
Sorry, we found nothing.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="history-holder">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="cp-pagination" id="pagination-area">
|
||||||
|
<nav aria-label="Page navigation"></nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).on("click", ".confrim-btn",function(){
|
||||||
|
if(!confirm("Are you sure?")){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
var urlVars = getUrlVars();
|
||||||
|
var pageNo = (urlVars["page"] ? parseInt(urlVars["page"]) : 1),
|
||||||
|
query = urlVars["q"],
|
||||||
|
loader = $("#history-loading"),
|
||||||
|
holder = $("#history-holder"),
|
||||||
|
errorArea = $("#error-msg-area"),
|
||||||
|
paginationArea = $("#pagination-area");
|
||||||
|
|
||||||
|
var getObjects = function(page){
|
||||||
|
pageNo = page;
|
||||||
|
holder.hide();
|
||||||
|
loader.show();
|
||||||
|
paginationArea.hide();
|
||||||
|
$.ajax({
|
||||||
|
url : "/cpanel/purchases",
|
||||||
|
data : {"page" : page, "query" : query},
|
||||||
|
dataType : "html",
|
||||||
|
type : "get"
|
||||||
|
}).done(function(html){
|
||||||
|
setTimeout(function(){
|
||||||
|
holder.html(html).show();
|
||||||
|
loader.hide();
|
||||||
|
var total_pages = parseInt(holder.find("input[type=hidden].total-pages").val());
|
||||||
|
if (total_pages > 1){
|
||||||
|
constructPagination(page, total_pages);
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
getObjects(pageNo);
|
||||||
|
//receipt toggle
|
||||||
|
$(document).on("click",".btn-receipt", function(event){
|
||||||
|
$(this).parent().siblings('.receipt-site').slideToggle();
|
||||||
|
event.preventDefault();
|
||||||
|
})
|
||||||
|
})
|
||||||
|
</script>
|
|
@ -6,7 +6,7 @@
|
||||||
<div class="link-user">
|
<div class="link-user">
|
||||||
<span><i class="fa fa-user-circle-o" aria-hidden="true"></i><%= current_cpanel_user.name %></span>
|
<span><i class="fa fa-user-circle-o" aria-hidden="true"></i><%= current_cpanel_user.name %></span>
|
||||||
<ul class="user-menu">
|
<ul class="user-menu">
|
||||||
<li><a href="#"><i class="fa fa-address-card" aria-hidden="true"></i>Profile</a></li>
|
<li><a href="/cpanel/myprofile"><i class="fa fa-address-card" aria-hidden="true"></i>Profile</a></li>
|
||||||
<li><a href="/cpanel/logout"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a></li>
|
<li><a href="/cpanel/logout"><i class="fa fa-sign-out" aria-hidden="true"></i>Logout</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,3 +52,4 @@ en:
|
||||||
amount_received: Amount Received
|
amount_received: Amount Received
|
||||||
amount_pending: Amount Pending
|
amount_pending: Amount Pending
|
||||||
receipt_status: Receipt Status
|
receipt_status: Receipt Status
|
||||||
|
loading_purchases: Loading Purchases
|
|
@ -52,3 +52,4 @@ zh_tw:
|
||||||
amount_received: Amount Received
|
amount_received: Amount Received
|
||||||
amount_pending: Amount Pending
|
amount_pending: Amount Pending
|
||||||
receipt_status: Receipt Status
|
receipt_status: Receipt Status
|
||||||
|
loading_purchases: Loading Purchases
|
|
@ -46,6 +46,7 @@ Rails.application.routes.draw do
|
||||||
# history
|
# history
|
||||||
get "history" => "client_managements#history", as: "cpanel_myhistory"
|
get "history" => "client_managements#history", as: "cpanel_myhistory"
|
||||||
get "contracts" => "client_managements#contracts", as: "cpanel_mycontracts"
|
get "contracts" => "client_managements#contracts", as: "cpanel_mycontracts"
|
||||||
|
get "purchases" => "client_managements#purchases", as: "cpanel_mypurchases"
|
||||||
get "request/:request_uid" => "client_managements#see_request"
|
get "request/:request_uid" => "client_managements#see_request"
|
||||||
get "contract/:contract_uid" => "client_managements#see_contract", as: "cpanel_contract_show"
|
get "contract/:contract_uid" => "client_managements#see_contract", as: "cpanel_contract_show"
|
||||||
patch "contract/:contract_uid/update_contract" => "client_managements#update_contract"
|
patch "contract/:contract_uid/update_contract" => "client_managements#update_contract"
|
||||||
|
|
Loading…
Reference in New Issue