<commit_before>{% extends "base.html" %}
{% load thing_extras %}

{% block title %}Assets{% endblock %}

{% block extra_head %}
    <script type="text/javascript">
      var characters = new Array();
      {% for character in characters %}
      characters[{{ forloop.counter0 }}] = new Array({{ character.id }}, "{{ character.name }}");
      {% endfor %}

      var corporations = new Array();
      {% for corporation in corporations %}
      corporations[{{ forloop.counter0 }}] = new Array({{ corporation.id }}, "{{ corporation.name }}");
      {% endfor %}

      var selected = new Array();
      {% for ft, fc, fv in filters %}
      {% if fv %}selected[{{ forloop.counter0 }}] = {{ fv }};{% endif %}
      {% endfor %}

      $(document).ready(function (){
        // bind value loader to type boxes
        $('#filters').on('change', '.filter-type', function() {
          $select = $(this).nextAll('.filter-value:first');
          $select.empty();

          var $v = $(this).val();
          if ($v == 'char') {
            for (i = 0; i < characters.length; i++) {
              $select.append($('<option>', { value: characters[i][0], selected: true }).text(characters[i][1]));
            }
          }
          else if ($v == 'corp') {
            for (i = 0; i < corporations.length; i++) {
              $select.append($('<option>', { value: corporations[i][0] }).text(corporations[i][1]));
            }
          }
          else {
            $select.append($('<option>', { value: '' }).text(''));
          }
        });

        // trigger each one to force an update
        $('.filter-type').each(function() {
          $(this).change();
        })

        // set them to the correct values
        var i = 0;
        $('.filter-value').each(function() {
          $(this).val(selected[i]);
          i++;
        });

        // bind the asset expander buttons
        $(".asset-expand").on('click', function() {
          var $this = $(this);
          
          if ($this.hasClass('icon-plus')) {
            $this.removeClass('icon-plus').addClass('icon-minus');
            $($this.attr('data-target')).each(function() {
              $(this).show();
            });
          }
          else {
            $this.removeClass('icon-minus').addClass('icon-plus');
            $($this.attr('data-target')).each(function() {
              $(this).hide();
            });
          }
        });
      });
    </script>
{% endblock %}

{% block content %}
      <div class="row-fluid">
        <div class="span8 alert alert-error">
          <i class="icon-info-sign"></i> <strong>WORK IN PROGRESS:</strong> this is pretty obviously a work in
          progress, more filter types need to be added and stuff.
        </div>
      </div>
      
      <div id="filters" class="row-fluid">
        <div class="span6">
          <h2>Assets</h2>

          <form class="well well-small" action="{% url thing.views.assets %}" method="GET">
            <h4>Filters</h4>
            <fieldset>
              {% for f_type, f_comp, f_value in filters %}
              <select name="type" class="filter-type input-medium">
                <option value=""></option>
                <option value="char"{% if f_type == 'char' %} selected{% endif %}>Character</option>
                {% if corporations|length %}
                <option value="corp"{% if f_type == 'corp' %} selected{% endif %}>Corporation</option>
                {% endif %}
              </select>
              <select name="comp" class="input-small">
                <option value="eq"{% if f_comp == 'eq' %} selected{% endif %}>=</option>
                <option value="ne"{% if f_comp == 'ne' %} selected{% endif %}>!=</option>
              </select>
              <select name="value" class="filter-value input-xlarge">
                <option value=""></option>
              </select>
              {% endfor %}
            </fieldset>
            {% comment %}<button id="add-filter" class="btn btn-primary"><i class="icon-plus icon-white"></i> Add filter</button>{% endcomment %}
            <button type="submit" class="btn btn-primary">Apply filters</button>
            <a href="{% url thing.views.assets %}" class="btn btn-danger">Clear filters</a>
          </form>
        </div>
      </div>

      <div class="row-fluid">
        <div class="span10">
          <p><strong>Total asset value:</strong> {{ total_value|commas }} ISK</p>
          {% for system_name, asset_roots in systems %}
          <table class="table table-striped table-bordered table-condensed">
            <thead>
              <tr class="c">
                <th class="l" colspan="2">{{ system_name }}</th>
                <th class="c">Group</th>
                <th class="c">Quantity</th>
                <th class="c">Unit Value</th>
                <th class="c">Total Value</th>
              </tr>
            </thead>
            <tbody>
              {% for asset in asset_roots %}
              <tr>
                <td class="assets-character">
                  {% if asset.corporation %}
                  <i class="icon-briefcase"></i> {{ asset.corporation.name }}
                  {% else %}
                  <i class="icon-user"></i> {{ asset.character.name }}
                  {% endif %}
                </td>
                <td class="assets-item">
                  {% if asset.z_contents %}<i class="icon-plus asset-expand" data-target=".asset-{{ asset.id }}"></i> {% endif %}
                  {{ asset.item.name }}
                  {% if asset.name %} - <i>{{ asset.name }}</i>{% endif %}
                </td>
                <td class="assets-type c">{{ asset.item.item_group.category.name }}</td>
                <td class="assets-quantity r">{{ asset.quantity|commas }}</td>
                <td class="assets-value r">{{ asset.item.sell_price|commas }} ISK</td>
                <td class="assets-value r">{{ asset.z_total|commas }} ISK</td>
              </tr>
              {% if asset.z_contents %}
              {% for content in asset.z_contents %}
              <tr class="asset-sneaky asset-{{ asset.id }}" style="display: none">
                <td></td>
                <td>
                  <i class="icon-arrow-right margin-left"></i>
                  {% if asset.z_locked %}<i class="icon-lock"></i>{% endif %}
                  {{ content.item.name }}
                </td>
                <td class="c">{{ content.z_group }}</td>
                <td class="r">{{ content.quantity|commas }}</td>
                <td class="r">{{ content.item.sell_price|commas }} ISK</td>
                <td class="r">{{ content.z_total|commas }} ISK</td>
              </tr>
              {% endfor %}
              {% if asset.z_mod == 1 %}<tr></tr>{% endif %}
              {% endif %}
              {% endfor %}
              <tr>
                <td colspan="4"></td>
                <td class="assets-total r" colspan="2">{{ loc_totals|dictlookup:system_name|commas }} ISK</td>
              </tr>
            </tbody>
          </table>
          {% endfor %}{% comment %}in systems{% endcomment %}<commit_msg>Add some stars for BPO types on 'assets' view<commit_after>{% extends "base.html" %}
{% load thing_extras %}

{% block title %}Assets{% endblock %}

{% block extra_head %}
    <script type="text/javascript">
      var characters = new Array();
      {% for character in characters %}
      characters[{{ forloop.counter0 }}] = new Array({{ character.id }}, "{{ character.name }}");
      {% endfor %}

      var corporations = new Array();
      {% for corporation in corporations %}
      corporations[{{ forloop.counter0 }}] = new Array({{ corporation.id }}, "{{ corporation.name }}");
      {% endfor %}

      var selected = new Array();
      {% for ft, fc, fv in filters %}
      {% if fv %}selected[{{ forloop.counter0 }}] = {{ fv }};{% endif %}
      {% endfor %}

      $(document).ready(function (){
        // bind value loader to type boxes
        $('#filters').on('change', '.filter-type', function() {
          $select = $(this).nextAll('.filter-value:first');
          $select.empty();

          var $v = $(this).val();
          if ($v == 'char') {
            for (i = 0; i < characters.length; i++) {
              $select.append($('<option>', { value: characters[i][0], selected: true }).text(characters[i][1]));
            }
          }
          else if ($v == 'corp') {
            for (i = 0; i < corporations.length; i++) {
              $select.append($('<option>', { value: corporations[i][0] }).text(corporations[i][1]));
            }
          }
          else {
            $select.append($('<option>', { value: '' }).text(''));
          }
        });

        // trigger each one to force an update
        $('.filter-type').each(function() {
          $(this).change();
        })

        // set them to the correct values
        var i = 0;
        $('.filter-value').each(function() {
          $(this).val(selected[i]);
          i++;
        });

        // bind the asset expander buttons
        $(".asset-expand").on('click', function() {
          var $this = $(this);
          
          if ($this.hasClass('icon-plus')) {
            $this.removeClass('icon-plus').addClass('icon-minus');
            $($this.attr('data-target')).each(function() {
              $(this).show();
            });
          }
          else {
            $this.removeClass('icon-minus').addClass('icon-plus');
            $($this.attr('data-target')).each(function() {
              $(this).hide();
            });
          }
        });
      });
    </script>
{% endblock %}

{% block content %}
      <div class="row-fluid">
        <div class="span8 alert alert-error">
          <i class="icon-info-sign"></i> <strong>WORK IN PROGRESS:</strong> this is pretty obviously a work in
          progress, more filter types need to be added and stuff.
        </div>
      </div>
      
      <div id="filters" class="row-fluid">
        <div class="span6">
          <h2>Assets</h2>

          <form class="well well-small" action="{% url thing.views.assets %}" method="GET">
            <h4>Filters</h4>
            <fieldset>
              {% for f_type, f_comp, f_value in filters %}
              <select name="type" class="filter-type input-medium">
                <option value=""></option>
                <option value="char"{% if f_type == 'char' %} selected{% endif %}>Character</option>
                {% if corporations|length %}
                <option value="corp"{% if f_type == 'corp' %} selected{% endif %}>Corporation</option>
                {% endif %}
              </select>
              <select name="comp" class="input-small">
                <option value="eq"{% if f_comp == 'eq' %} selected{% endif %}>=</option>
                <option value="ne"{% if f_comp == 'ne' %} selected{% endif %}>!=</option>
              </select>
              <select name="value" class="filter-value input-xlarge">
                <option value=""></option>
              </select>
              {% endfor %}
            </fieldset>
            {% comment %}<button id="add-filter" class="btn btn-primary"><i class="icon-plus icon-white"></i> Add filter</button>{% endcomment %}
            <button type="submit" class="btn btn-primary">Apply filters</button>
            <a href="{% url thing.views.assets %}" class="btn btn-danger">Clear filters</a>
          </form>
        </div>
      </div>

      <div class="row-fluid">
        <div class="span10">
          <p><strong>Total asset value:</strong> {{ total_value|commas }} ISK</p>
          {% for system_name, asset_roots in systems %}
          <table class="table table-striped table-bordered table-condensed">
            <thead>
              <tr class="c">
                <th class="l" colspan="2">{{ system_name }}</th>
                <th class="c">Group</th>
                <th class="c">Quantity</th>
                <th class="c">Unit Value</th>
                <th class="c">Total Value</th>
              </tr>
            </thead>
            <tbody>
              {% for asset in asset_roots %}
              <tr>
                <td class="assets-character">
                  {% if asset.corporation %}
                  <i class="icon-briefcase"></i> {{ asset.corporation.name }}
                  {% else %}
                  <i class="icon-user"></i> {{ asset.character.name }}
                  {% endif %}
                </td>
                <td class="assets-item">
                  {% if asset.z_contents %}<i class="icon-plus asset-expand" data-target=".asset-{{ asset.id }}"></i> {% endif %}
                  {% if asset.item.item_group.category.name == 'Blueprint' %}
                  {{ asset.raw_quantity }}
                  {% if asset.raw_quantity == -1 %}<i class="icon-star" rel="tooltip" title="Original"></i>{% endif %}
                  {% if asset.raw_quantity == -2 %}<i class="icon-star-empty" rel="tooltip" title="Copy"></i>{% endif %}
                  {% endif %}
                  {{ asset.item.name }}
                  {% if asset.name %} - <i>{{ asset.name }}</i>{% endif %}
                </td>
                <td class="assets-type c">{{ asset.item.item_group.category.name }}</td>
                <td class="assets-quantity r">{{ asset.quantity|commas }}</td>
                <td class="assets-value r">{{ asset.item.sell_price|commas }} ISK</td>
                <td class="assets-value r">{{ asset.z_total|commas }} ISK</td>
              </tr>
              {% if asset.z_contents %}
              {% for content in asset.z_contents %}
              <tr class="asset-sneaky asset-{{ asset.id }}" style="display: none">
                <td></td>
                <td>
                  <i class="icon-arrow-right margin-left"></i>
                  {% if content.z_locked %}<i class="icon-lock"></i>{% endif %}
                  {% if content.item.item_group.category.name == 'Blueprint' %}
                  {% if content.raw_quantity == -1 %}<i class="icon-star" rel="tooltip" title="Original"></i>{% endif %}
                  {% if content.raw_quantity == -2 %}<i class="icon-star-empty" rel="tooltip" title="Copy"></i>{% endif %}
                  {% endif %}
                  {{ content.item.name }}
                </td>
                <td class="c">{{ content.z_group }}</td>
                <td class="r">{{ content.quantity|commas }}</td>
                <td class="r">{{ content.item.sell_price|commas }} ISK</td>
                <td class="r">{{ content.z_total|commas }} ISK</td>
              </tr>
              {% endfor %}
              {% if asset.z_mod == 1 %}<tr></tr>{% endif %}
              {% endif %}
              {% endfor %}
              <tr>
                <td colspan="4"></td>
                <td class="assets-total r" colspan="2">{{ loc_totals|dictlookup:system_name|commas }} ISK</td>
              </tr>
            </tbody>
          </table>
          {% endfor %}{% comment %}in systems{% endcomment %}
{'fraction_non_alphanumeric': 0.18461845519260195, 'fraction_numerical': 0.003193400306034196, 'mean_word_length': 1.6733060643784456, 'pattern_counts': {'":': 0, '<': 261, '<?xml version=': 0, '>': 257, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2945984', 'n_tokens_mistral': 4545, 'n_tokens_neox': 4160, 'n_words': 945}