{% extends "admin/change_form.html" %}

{% block object-tools-items %}
{% if user.is_superuser %}
<li><a href="/admin/extras/print/?app_label={{ opts.app_label }}&model={{ opts.model_name }}&id={{original.id}}" target="blank">Imprimír</a></li>
{% endif %}

<li><a href="#" id="btn-print" class="have-info"
       data-url="/caja/blog/?app={{ opts.app_label }}&model={{ opts.model_name }}&instance={{original.id}}&_popup=1"
       data-name="{{ original.nombre }}">Corréos e Información Relacionada</a></li>
{{ block.super }}
{% endblock %}


{% block extrahead %}
<script type="text/javascript">
  (function($) {
    $(document).ready(function(){
      var show_info = function(){
        window.open($(this).data('url'), $(this).data('name'), "width=1100mm, height=500mm,  status=no, scrollbars=no, toolbars=no, menubar=no, location=no");
      }

       var execute = function () {
           $.ajax('/ajax/object_execute/', {
               method: 'POST',
               data: {app_label: $(this).data('app-label'),
                   model: $(this).data('model'),
                   id: $(this).data('id'),
                   method: $(this).data('method'),},
               success: function (result) {
                   location.reload();
               }
           })
       }

    $('.have-info').on('click', show_info);

    $('.btn-execute').on('click', execute);

        {% block jquery %}

        {% endblock %}
      });
  })(grp.jQuery)
</script>
{% endblock %}