epaper/app/views/admin/e_paper_criterias/_index.html.erb

115 lines
4.4 KiB
Plaintext
Raw Normal View History

2019-05-28 15:54:32 +00:00
<table class="table main-list">
<thead>
<tr class="sort-header">
<% @table_fields.each do |f| %>
<%= thead(f) %>
<% end %>
</tr>
</thead>
<tbody>
<% @criterias.each do |criteria| %>
<tr>
<td>
<%= criteria.title %>
<div class="quick-edit">
<ul class="nav nav-pills">
<li><a href="<%= edit_admin_e_paper_criteria_path(criteria.id) %>"><%= t(:edit) %></a></li>
<li><a class="test-email" href="<%= send_test_email_admin_e_paper_criteria_path(criteria.id) %>"><%= t('e_paper.test_mail') %></a></li>
<li><a class="send-newsletter" href="<%= send_newsletter_admin_e_paper_criteria_path(criteria.id) %>"><%= t('e_paper.send_newsletter') %></a></li>
2020-08-28 12:49:47 +00:00
<li><a class="get_failed_emails" href="<%= get_failed_emails_admin_e_paper_criteria_path(criteria.id) %>"><%= t('e_paper.get_failed_emails') %></a></li>
<li><a class="get_failed_emails" href="<%= get_invalid_emails_admin_e_paper_criteria_path(criteria.id) %>"><%= t('e_paper.get_invalid_emails') %></a></li>
2019-05-28 15:54:32 +00:00
<li><a class="delete text-error" href="<%= admin_e_paper_criteria_path(criteria.id) %>" data-method="delete" data-confirm="Are you sure?"><%= t(:delete_) %></a></li>
</ul>
</div>
</td>
<td><%= criteria.start_date.strftime("%Y/%m/%d") rescue "N/A" %> ~ <%= criteria.end_date.strftime("%Y/%m/%d") rescue "N/A" %></td>
</tr>
<% end %>
</tbody>
</table>
2020-08-28 12:49:47 +00:00
<div id="show_epaper_message"></div>
2019-05-28 15:54:32 +00:00
<div class="bottomnav clearfix" style="left: 81px;">
<%= content_tag :div, paginate(@criterias), class: "pagination pagination-centered" %>
<div class="action pull-right">
<a class="btn btn-primary" href="<%= new_admin_e_paper_criteria_path %>">
<%= t("e_paper.new_criteria") %>
</a>
</div>
</div>
2020-08-28 12:49:47 +00:00
<style type="text/css">
#show_epaper_message span {
background: #9C27B0;
color: white;
}
</style>
2019-05-28 15:54:32 +00:00
<script type="text/javascript">
2020-08-28 12:49:47 +00:00
function convert_email_to_html(data){
return ('count:&nbsp;'+data.length+'<br><pre><span>'+data.join('</span></pre><br><pre><span>')+'</span></pre>')
}
2019-05-28 15:54:32 +00:00
$(".test-email").on("click",function(){
var el = $(this),
email = prompt("Please enter an email address to send test email.", "<%= current_user.member_profile.email rescue "" %>");
if(email != null){
$.ajax({
url : el.attr("href"),
data : {"email" : email},
dataType : "json",
type : "get"
}).done(function(){
alert("Email sent.")
})
}
return false;
})
$(".send-newsletter").on("click",function(){
var el = $(this);
if(confirm("Are you sure?")){
$.ajax({
url : el.attr("href"),
dataType : "json",
2020-08-28 12:49:47 +00:00
type : "get",
success: function(data){
if (data.success){
alert("Newsletter sent.")
}else{
var window_width = window.innerWidth
var window_height = window.innerHeight
var show_html = (typeof(data.invalid_emails)=='string' ? data.invalid_emails : convert_email_to_html(data.invalid_emails))
$("div#show_epaper_message").html(show_html)
$("div#show_epaper_message").dialog({
autoOpen: true,
show: "blind",
model: true,
hide: "explode",
width: window_width*0.7,
height: window_height*0.6
})
}
}
})
}
return false;
})
2020-08-28 12:49:47 +00:00
$('.get_failed_emails').on('click',function(){
$.ajax({
url : $(this).attr("href"),
dataType : "json",
type : "get",
success: function(data){
var window_width = window.innerWidth
var window_height = window.innerHeight
var show_html = (typeof(data.data)=='string' ? data.data : convert_email_to_html(data.data))
$("div#show_epaper_message").html(show_html)
$("div#show_epaper_message").dialog({
autoOpen: true,
show: "blind",
model: true,
hide: "explode",
width: window_width*0.7,
height: window_height*0.6
})
}
})
return false;
})
2019-05-28 15:54:32 +00:00
</script>