{% include 'header.twig' %}

<style>
    .card-head{
    background: none;
}

</style>
<!-- Main variables *content* -->
    {% if settings['ticket_system'] == 1 %}
<div class="wrapper-content">
    <div class="wrapper-content__header">
        <!-- Header content -->
    </div>
    <div class="wrapper-content__body">
        <!-- Main content -->
        <div id="block_93">
            <div class="ticket-form">
                <div class="bg"></div>
                <div class="divider-top"></div>
                <div class="divider-bottom"></div>
                <div class="container">
                    <div class="card mt-2 mb-2">
                        {% if contentText %}
                            {{ contentText }}
                        {% endif %}
                    </div>
                    <div class="row ticket-form__alignment">
                        <div class="col-lg-6" style="
    margin-top: 72px;
">
                            <div class="component_card">
                                <div class="card mt-2 mb-2" style="
    padding: 20px;
">
                                    {% 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="well">
                                    
            {{ ticketCode.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" class="form-control" value="{{ search }}" placeholder="Search tickets">
                                                            <div class="input-group-append component_button_search">
                                                                <button class="btn btn-big-primary" type="submit" style="
    background: #FF7700;
">
                                                                    <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">
                                            <div class="table-wr table-responsive">
                                                <table class="table mt-2">
                                                    <thead>
                                                        <tr>
                                                            <th>ID</th>
                                                            <th>Subject</th>
                                                            <th>Status</th>
                                                            <th class="nowrap">Last update</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="nowrap">{{ ticket['lastupdate_time'] }}</span></td>
    </tr>
{% endfor %}

                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        {% 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>
{% endif %}

<div id="block_81">
    <div class="tickets-list">
        <div class="bg"></div>
        <div class="divider-top"></div>
        <div class="divider-bottom"></div>
        <div class="container">
            <div class="row tickets-list__alignment">
                <!-- Additional content if needed -->
            </div>
        </div>
    </div>
</div>
 <script>
      function HideEverything(){
        $('.payment').hide();
        $('.ordernumbers').hide();
        $('.therequest').hide();
        $('.transactionid').hide();
      }
      $(document).ready(function(){
      $('.subject').change(function(){
            HideEverything();		
            if($(this).val()=='Order'){
                $('.therequest').show();
                $('.ordernumbers').show();
                $('#requestRefill').prop('checked',true);
                $('#paymentPaypal').prop('checked',false);
            }  		
            if($(this).val()=='Payment'){
                $('.payment').show();
                $('.transactionid').show();
                $('#paymentPaypal').prop('checked',true);
                $('#requestRefill').prop('checked',false);
            }
        });

        
        $("#requestCancellation").on("click", function(){
            check = $(this).prop("checked");
            $("#reason").removeClass("hidden");
            $('#requestRefill').prop('checked',false);
            $('#requestOther').prop('checked',false);
            $('#requestSpeed').prop('checked',false);
        });
        
        $("#requestRefill").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });
        
        $("#requestRefill").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });

        $("#requestOther").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });

        $("#requestSpeed").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });	
    
        $("#subjectPayment").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });	
        
        $("#subjectService").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });	
        
        $("#subjectFRP").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });	
        
        $("#subjectOther").on("click", function(){
            check = $(this).prop('checked',true);
            $('#requestCancellation').prop('checked',false);
            $("#reason").addClass("hidden");
        });	        
        
        $('#submit').click(function(e){
            e.preventDefault();
            console.log('working');
            $TheSubject = $('.subject:checked').val();
            $TheRequest = $('.second-options:checked').val();
            $FinalSubject = $('.subject:checked').val();
            if ($TheSubject == 'Order'){
                $final = 'Order Request: ' + $TheRequest + '\n\nOrder ID: ' + $('#ordernumbers').val() + '\n\n' + '\n\nReason: ' + $('#reasoncancel').val() + '\n\n' + $('#message').val();
                $FinalSubject += ' - ' + $TheRequest;
            }else if($TheSubject == 'Payment'){
                $final = $TheSubject + ': ' + $TheRequest + '\n' + 'Transaction ID:' +  $('#transactionid').val() +'\n\n' + $('#message').val();
                $FinalSubject += ' - ' + $TheRequest + ' - ' + $('#transactionid').val().substring(0,30);
            }else{
                $final = $('#message').val();
            }
            $('#alldata').val($final);
            $('.subject:checked').val($FinalSubject);
            //submit
            $('#submit').submit();
        });
      });
    </script>		  

        


      
      <div class="mobile-navbar">
        <div class="mobile-navbar-content">
            <a href="/" class="mnc-item">
                <div class="mnc-item-icon">
                    <i class="far fa-box-heart"></i>
                </div>
                <div class="mnc-item-text">New order</div>
            </a>
            <a href="/addfunds" class="mnc-item">
                <div class="mnc-item-icon">
                    <i class="ri-exchange-dollar-line"></i>
                </div>
                <div class="mnc-item-text">Add funds</div>
            </a>
            <a href="/tickets" class="mnc-item">
                <div class="mnc-item-icon">
                    <i class="ri-customer-service-2-line"></i>
                </div>
                <div class="mnc-item-text">Tickets</div>
            </a>
            <a href="/services" class="mnc-item">
                <div class="mnc-item-icon">
                    <i class="ri-list-check-2"></i>
                </div>
                <div class="mnc-item-text">Services</div>
            </a>
        </div>
    </div>
  
       <div class="bs-toast">
         <div class="bs-toast-content">
            <div class="toast-text">Copy to clipboard</div>
         </div>
      </div>

      <div class="overlay"></div>
     



{% include 'footer.twig' %}