{% load static %}

<div class="card" id="widget-card-{{widget.pk}}" widget-id="{{ widget.pk }}">

    <!--SECTION KPI-->
    <div class="card-body">
        <h4 class="card-title">{{widget.name}}</h4>

        <!--TABLE RESULT-->
        {% if widget.output_type == 'table' %}
        <div
          class="table-responsive overflow-auto"
        >
            <table class="table table-striped">
                <thead>
                  <tr>
                    {% for col in result.columns %}
                    <th scope="col">{{col|title}}</th>
                    {% endfor %}
                  </tr>
                </thead>
                <tbody>
                    {% for row in result.data %}
                    <tr>
                        {% for cell in row %}
                        <td>{{cell}}</td>
                        {% endfor %}
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
        <!--END TABLE RESULT-->

        {% elif widget.output_type == 'value' %}

            <div class="d-flex align-items-center">
            <div class="card-icon rounded-circle d-flex align-items-center justify-content-center" style="background:{{widget.options.color}}">
              <i class="{{widget.options.icon}}"></i>
            </div>
            <div class="ps-3">
              <h4>{{widget.options.prefix}} {{widget.result_value}} {{widget.options.suffix}}</h4>
              <span class="text-muted small pt-2 ps-1">{{widget.desctiption}}</span>

            </div>
          </div>

        {% else %}
          <div class="overflow-auto">
            {{result|safe}}
          </div>
        {% endif %}


    </div>
    <!--END SECTION KPI-->
</div>

