{% include 'header.twig' %}

<style>
    button.btn.btn-block.btn-big-primary {
    background: #2272d6;
    color: white;
}a {
    color: #0288D1;
    text-decoration: none;
    background-color: transparent;
    font-weight: 700;
}
</style>
{% if settings['ticket_system'] == 1 %}

<section>
    
     <div class="container">
       
	 {% if contentText %}
                        <div class="col-lg-12 mt-2">
                            <div class="card mb-2" style="padding: 1rem; border-radius: 0.25rem; background-color: #fff; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
                                {{ contentText }}
                            </div>
                        </div>
                    {% endif %}

            <div class="row ticket-form__alignment">
                <div class="col-lg-6 ">
                   <div class="component_card">
                      <div class="">

      {% if error %}
        <div class="alert alert-dismissible alert-danger {% if site['rtl'] %} rtl-alert {% endif %}">
          <button type="button" class="close" data-dismiss="alert">×</button>
          {{ errorText }}
        </div>
      {% elseif success %}
        <div class="alert alert-dismissible alert-success {% if site['rtl'] %} rtl-alert {% endif %}">
          <button type="button" class="close" data-dismiss="alert">×</button>
          {{ successText }}
        </div>
      {% endif %}


        <div class="">
          <form method="post" action="tickets">
            <div class="form-group">
              <label for="subject" class="control-label">{{ lang['tickets.subject'] }}</label>
              
<select type="text" class="form-control" id="subject" name="subject">
                                  <option value="Order">Order</option>
                                  <option value="Service">Service</option>
                                  <option value="Child Panel">Child Panel</option>
                                  <option value="API">API</option>
                                  <option value="Bug Report">Bug Report</option>
                                  <option value="-Request">Request</option>
                                  <option value="Other">Other</option>
                              </select>           </div>
            <div class="form-group">
              <label for="message" class="control-label">{{ lang['tickets.message'] }}</label>
              <textarea class="form-control" rows="7" id="message" name="message">{{ data['message'] }}</textarea>
            </div>
            <button type="submit" class="btn btn-block btn-big-primary">{{ lang['tickets.button'] }}</button>
          </form>
        </div>
        </div>
        </div>
        </div>
        <div class="col-lg-6  ">
                    <div class="row">
                        <div class="col-12">
                            <div class="tickets-list__margin-search component_card">
                                <div class="card mt-2 mb-2">
                                    <div class="component_form_group">
                                        <div class="">
                                            <form action="/tickets" method="get" id="history-search">
                                                <div class="input-group">
                                                    <input type="text" name="search" style="width:0%;"class="form-control" value="" placeholder="Search tickets">
                                                    <div class="input-group-append component_button_search">
                                                        <button class="btn btn-big-primary" type="submit"style="margin-top:0px;box-shadow:none;">
                                                            <span class="fas fa-search"></span>
                                                        </button>
                                                    </div>
                                                </div>
                                            </form>
                                        </div>
                                   </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col">
                            <div class="tickets-list__margin-table">
                                <div class="table-bg component_table mt-2">
                                    <div class="table-wr table-responsive">
                                        <table class="table">
                                            <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Subject</th>
                                                <th>Status</th>
                                                <th class="nowrap">Last update</th> <th class="nowrap">View</th>
                                            </tr>
                                            </thead>
                                            <tbody>

              {% for ticket in ticketList %}
                <tr>
                  <td>{{ ticket['ticket_id'] }}</td>
                  {% if ticket["support_new"] == 2 %}
                    <td><a href="tickets/{{ ticket['ticket_id'] }}"><strong>{{ ticket['subject'] }}</strong></a></td>
                  {% else %}
                    <td><a href="tickets/{{ ticket['ticket_id'] }}">{{ ticket['subject'] }}</a></td>
                  {% endif %}
                  <td>{{ ticket['status'] }}</td>
                  <td><span class="wrap">{{ ticket['lastupdate_time'] }}</span></td>
                    <td><a class="read" href="tickets/{{ ticket['ticket_id'] }}"><strong></strong>VIew Ticket</a></td>
                </tr>
              {% endfor %}
</td>
            </tbody>
          </table>
        </div>
      </div>
  </div>
</div> </div></div>
        </div>
        </div>
      

        <div class="container">
            <div class="row tickets-list__alignment">
                

{% if pagination["count"] > 1 %}
        <ul class="pagination">

          {% if pagination["current"] != 1 %}
            <li>
              <a href="tickets/{{ id }}/{{ pagination["previous"] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Previous">
                <span aria-hidden="true">«</span>
              </a>
            </li>
          {% endif %}

          {% set r, l = 3, 3 %}

          {% if pagination['current'] == 1 %}
            {% set r = 7 %}
          {% endif %}

          {% if pagination['current'] == 2 %}
            {% set r = 5 %}
          {% endif %}

          {% if pagination['current'] >= pagination['count'] %}
            {% set l = 5 %}
          {% endif %}

          {% for page in 1..pagination["count"] %}
            {% if page >= (pagination['current']-l) and page <= (pagination['current']+r) %}
              <li{% if page == pagination['current'] %} class="active" {%endif%}><a href="tickets/{{ id }}/{{ page }}{% if search %}?search={{ search }}{% endif %}">{{ page }}</a></li>
            {%endif%}
          {% endfor %}

          {% if pagination['current'] < pagination['count'] %}
            <li>
              <a href="ticket/{{ id }}/{{ pagination['next'] }}{% if search %}?search={{ search }}{% endif %}" aria-label="Next">
                <span aria-hidden="true">»</span>
              </a>
            </li>
          {% endif %}

        </ul>
      {% endif %}

    </div></div>



  

        <div class="container">
 
	 {% if contentText %}
                        <div class="col-lg-12 mt-2">
                            <div class="card mb-2" style="padding: 1rem; border-radius: 0.25rem; background-color: #fff; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);">
                                {{ contentText }}
                            </div>
                        </div>
                    {% endif %}
</div>

</section>
       {% endif %}


{% include 'footer.twig' %}
