modify expire page

This commit is contained in:
Zin Moe
2020-06-18 18:02:02 +06:30
parent b46cefc8bc
commit 02ba0f21e6
5 changed files with 46 additions and 22 deletions

View File

@@ -10,8 +10,7 @@ class RenewLicenseController < ApplicationController
def renew
status, message = current_license.verify_license
redirect_to expire_url(message: message, status: status)
render json: {message: message, status: status}
end
end
end

View File

@@ -170,6 +170,10 @@ class License
else
delete_license_file
stauts = 0
message = "*** Your license has been expired. ***"
return status, message
end
rescue SocketError => e

View File

@@ -2,10 +2,14 @@
<% date_count = (renewable_date.to_date - Date.today).to_i %>
<% day = pluralize( date_count, 'day' )%>
<% if @license_status == 0
<% if @license_status == 0
text = 'Your license has been expired.'
elsif @license_status == 2
text = "Your license will expire in #{day}."
if date_count == 0
text = "Your license will expire in tomorrow."
else
text = "Your license will expire in #{day}."
end
end
%>
<style>
@@ -27,17 +31,9 @@
<div class="card-block">
<h3 class="pt-2 d-inline">Review Your License</h3>
<%= link_to origami_dashboard_url do %>
<img src="/image/logo.png" style="margin-left: 25pc; width: 150px">
<% end %>
<% if params[:message].present?
if params[:status].to_i == 1
color = 'text-success'
else
color = 'text-danger'
end
%>
<p class="<%= color %> m-t--30" style="font-weight: bold; font-size: 18px;"><%= params[:message] %></p><br>
<img src="/image/logo.png" style="margin-left: 25pc; width: 140px">
<% end %>
<p class="m-t--30" id="warning_text" style="font-weight: bold; font-size: 18px;"></p><br>
<% if text %>
<h6 class="mb-2 "><%= text %></h6><br>
<% end %>
@@ -56,7 +52,7 @@
<label class="card-subtitle mb-2 "><strong><%= @plan %></strong></label>
</div>
</div>
<div class="form-group row">
<label class="card-subtitle mb-2 col-md-4 pl-4">Expired At: </label>
<label class="card-subtitle mb-2 "><strong><%= @expired_at.to_date.strftime('%B %d, %Y') %></strong></label>
@@ -64,8 +60,10 @@
</div>
<br>
<div class="col-md-12" style="padding-bottom: 20px;">
<%= link_to 'Review License', renew_url, class: 'btn btn-primary btn-lg float-right m-l-10 m-r-5' %>
<%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right' %>
<button type="button" class="btn btn-primary btn-lg float-right m-l-10 m-r-5" id="review_license">
Review License
</button>
<%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right', id: 'go_to_home' %>
</div>
</div>
<div class="col-sm-2"></div>
@@ -74,9 +72,28 @@
<script>
$(document).ready(function() {
$('.alert-danger, .navbar').hide()
$('.alert-danger, .navbar, #warning_text').hide()
$('html, section').css('background-color', '#61B8C9')
// $('html').css('overflow-x', 'hidden')
$('section.content').css('margin', '70px 0 0 0')
$('#review_license').on ('click', function() {
$.ajax({
url: '/renew',
type: 'POST',
success: function(res) {
if (res.message.length != 0) {
if (res.status == 1) {
color = 'text-success'
} else if (res.status == 2) {
color = 'text-danger'
} else {
color = 'text-danger'
$('#go_to_home').hide()
}
$('#warning_text').addClass(color).text(res.message).show()
}
}
})
})
})
</script>

View File

@@ -6,7 +6,11 @@
<% if license_status == 0
text = 'Your license has expired.'
elsif license_status == 2
text = "Your license will expire in #{day}."
if date_count == 0
text = "Your license will expire in tomorrow."
else
text = "Your license will expire in #{day}."
end
end
%>
<% if license_status == 0 || license_status == 2 %>

View File

@@ -30,7 +30,7 @@ scope "(:locale)", locale: /en|mm/ do
get 'dashboard' => 'home#dashboard'
get 'expire' => 'renew_license#expire'
get 'renew' => 'renew_license#renew'
post 'renew' => 'renew_license#renew'
namespace :induties do
# resources :assign_in_duties