announcement-test/app/views/admin/announcements/import.html.erb

87 lines
3.8 KiB
Plaintext
Raw Normal View History

<% content_for :page_specific_javascript do %>
<script type="text/javascript" src="/assets/validator.js"></script>
<% end %>
<form action="<%= admin_announcement_importanns_path %>" method="post" class="form-horizontal main-forms" id="import-anns-xls" enctype="multipart/form-data">
2018-01-19 09:05:26 +00:00
<h3 style="padding-left: 30px;"><%= t("announcement.export_to_excel") %></h3>
2017-01-16 07:14:57 +00:00
<div class="control-group">
<div class="controls">
2018-01-19 09:05:26 +00:00
<a href="<%= admin_announcement_export_excel_path(:format => "xlsx") %>"><%= t("announcement.export_all_anns") %></a>
2017-01-16 07:14:57 +00:00
</div>
</div>
2018-01-19 09:05:26 +00:00
<h3 style="padding-left: 30px;"><%= t("announcement.import_from_excel") %></h3>
2016-04-21 17:28:37 +00:00
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="input-area">
<% if @module_app.categories.count > 0 %>
<div class="control-group">
<div class="controls">
2018-01-19 09:05:26 +00:00
<a href="<%= admin_announcement_excel_format_path(:format => "xlsx") %>"><%= t("announcement.download_example_sheet_here") %></a>
2016-04-21 17:28:37 +00:00
</div>
</div>
<div class="control-group">
2018-01-19 09:05:26 +00:00
<label for="import-anns" class="control-label muted"><%= t("upload") %></label>
2016-04-21 17:28:37 +00:00
<div class="controls">
<input type="file" id="import-anns" name="import_file" data-fv-validation="required;mustbexls;" data-fv-messages="Cannot be empty; Must be an excel file.;" />
2018-01-19 09:05:26 +00:00
<span class="help-block"><%= t("announcement.please_create_tags_cats") %></span>
2016-04-21 17:28:37 +00:00
</div>
</div>
<% else %>
<div class="control-group">
<div class="controls">
2018-01-19 09:05:26 +00:00
<h4><%= t("announcement.create_atleast_one_cat") %></h4>
2016-04-21 17:28:37 +00:00
</div>
</div>
<% end %>
</div>
<% if @module_app.categories.count > 0 %>
<div class="form-actions">
2018-01-19 09:05:26 +00:00
<input type="submit" value="<%= t("restful_actions.import") %>" class="btn btn-primary">
2016-04-21 17:28:37 +00:00
</div>
<% end %>
</form>
2017-01-26 06:30:59 +00:00
<!-- import from wp xml -->
<form action="<%= admin_announcement_import_from_wp_path %>" method="post" class="form-horizontal main-forms" id="import-anns-wp-xml" enctype="multipart/form-data">
2018-01-19 09:05:26 +00:00
<h3 style="padding-left: 30px;"><%= t("announcement.import_from_wp_xml") %></h3>
2017-01-26 06:30:59 +00:00
<%= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="input-area">
<div class="control-group">
2018-01-19 09:05:26 +00:00
<label for="import-anns-wp-xml" class="control-label muted"><%= t("upload") %></label>
2017-01-26 06:30:59 +00:00
<div class="controls">
<input type="file" id="import-anns-wp-xml" name="import_xml" data-fv-validation="required;mustbexml;" data-fv-messages="Cannot be empty; Must be an XML file.;" />
</div>
</div>
</div>
<div class="form-actions">
2018-01-19 09:05:26 +00:00
<input type="submit" value="<%= t("restful_actions.import") %>" class="btn btn-primary">
2017-01-26 06:30:59 +00:00
</div>
</form>
2018-01-19 09:05:26 +00:00
<!-- <form action="<%#= admin_announcement_import_from_xml_path %>" method="post" class="form-horizontal main-forms" id="import-anns-xml" enctype="multipart/form-data">
<h3 style="padding-left: 30px;">Import from XML</h3>
<%#= hidden_field_tag :authenticity_token, form_authenticity_token %>
<div class="input-area">
<div class="control-group">
<label for="import-anns" class="control-label muted">URL :</label>
<div class="controls">
<input type="text" id="import-anns" name="import_xml" data-fv-validation="required;url;" data-fv-messages="Cannot be empty; Must be an URL.;" />
</div>
</div>
</div>
<div class="form-actions">
<input type="submit" value="Import" class="btn btn-primary">
</div>
</form> -->
<script type="text/javascript">
var form = new FormValidator($("#import-anns-xls"));
form.validate_functions.mustbexls = function(val){
var t = val.split("."),
ext = t[t.length - 1];
return (ext == "xls" || ext == "xlsx")
}
2017-01-26 06:30:59 +00:00
var form = new FormValidator($("#import-anns-wp-xml"));
form.validate_functions.mustbexml = function(val){
var t = val.split("."),
ext = t[t.length - 1];
return (ext == "xml")
}
</script>