{% extends "layout/baseadmin.html.twig" %}
{% block content %}
    <div class="widget">
        <div class="widget-body">
            <table id="product-list" class="table table-hover dt-responsive nowrap">
                <thead>
                <tr>
                    <th>Title</th>
                    <th>Course Start Date</th>
                   
                    <th>Event Time Start</th>
                    <th>Participants</th>
                    <th>Course income</th>
                    <th>Course End Date</th>
                    <th>actions</th>
                </tr>
                </thead>
                <tbody>


                {% for cource in cources %}
                
                    <tr>
                 
                        <td>{{ cource.title }}</td>
                        <td>{{ cource.courseStart ? cource.courseStart|date('Y-m-d') : '' }}</td>
                        <td>{{ cource.eventtimeStart ? cource.eventtimeStart|date('H:i:s') : '' }}</td>
                        <td>{{ cource.Buy|length }}</td>

                        <td>{{ cource.Buy|length * cource.price }} AED</td>
                        <td>{{ cource.courseEnd ? cource.courseEnd|date('Y-m-d') : '' }}</td>
                        <td>
                            <a href="#" data-toggle="modal" data-target=".bs-view{{cource.id  }}" class="btn btn-outline btn-success"><i class="ti-eye"></i></a>

                           <a href="#"  data-toggle="modal" data-target=".bs-delete1{{cource.id  }}" class="btn btn-outline btn-primary"><i class="ti-eye"></i></a> 
                            <form method="post" action="{{ path('cource_delete_admin', {'id': cource.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
                                <input type="hidden" name="_method" value="DELETE">
                                <input type="hidden" name="_token" value="{{ csrf_token('delete' ~ cource.id) }}">
                                <button class="btn btn-outline btn-danger"><i class="ti-trash"></i></button>
                            </form>
                        </td>
                        <div tabindex="-1" role="dialog" aria-labelledby="modalWithForm01" class="modal fade bs-view{{cource.id  }}">
                            <div role="document" class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <div class="text-left">
                                            <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                            <h4 id="modalWithForm01" class="modal-title">Course details</h4>
                                        </div>
                                    </div>
                                    <div class="modal-body">
                                        <div class="form-group">
                                            <label for="phoneNumber1">Course Title</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.title }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Description : </label><br>
                                        <textarea class="form-control" name="description" id="" rows="3" disabled>{{ cource.description}}</textarea>
                                         
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Price (AED)</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.price }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Event Time Start</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.eventtimeStart ? cource.eventtimeStart|date('H:s') : '' }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Event Time End</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.eventtimeEnd ? cource.eventtimeEnd|date('H:s') : '' }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Cource start date</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.courseStart ? cource.courseStart|date('Y-m-d') : '' }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Course End Date (Delete course at this date  )</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.courseEnd ? cource.courseStart|date('Y-m-d') : '' }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Course Place</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.place }}" disabled class="form-control focus">
                                        </div>

                                        <div class="form-group">
                                            <label for="phoneNumber1">Course category</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.category }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Full name of the main trainer</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.fullnamesecandary }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">discount (%)
                                                {% if cource.discount==1 %}
                                                    <span>True</span>
                                                {% else %}
                                                    <span>False</span>
                                                {% endif %}


                                            </label>
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Seats limit
                                                {% if cource.limite==1 %}
                                                <span>True</span>
                                            {% else %}
                                                <span>False</span>
                                                {% endif %}

                                            </label>
                                        </div>
                                        <div class="form-group">
                                            <label for="phoneNumber1">Discount</label>
                                            <input id="phoneNumber1" type="text"  value="{{ cource.discountVal }}" disabled class="form-control focus">
                                        </div>
                                        <div class="form-group">
                                            {% for photo in cource.photos %}
                                                <img src="/uploads/files/{{photo.path  }}" alt="" class="photoblog">
                                            {% endfor %}

                                        </div>

                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" data-dismiss="modal" class="btn btn-raised btn-black">Cancel</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div tabindex="-1" role="dialog" aria-labelledby="myModalLabelDelete1" class="modal fade bs-delete1{{cource.id  }}">
                    <div role="document" class="modal-dialog modal1">
                        <div class="modal-content">
                            <div class="modal-header">
                                <div class="text-left">
                                    <button type="button" data-dismiss="modal" aria-label="Close" class="close"><span aria-hidden="true">×</span></button>
                                    <h4 id="myModalLabelDelete1" class="modal-title">The Buyers</h4>
                                </div>
                            </div>
                            <div class="modal-body">
                            <div class="form-group">
                                <strong class="col-sm-6 control-label">fullName</strong>    
                              <strong class="col-sm-6 control-label">Email</strong>
                             {% for b in cource.Buy %}
                                  <p class="col-sm-6 control-label">{{ b.Participant.fullName }}</p>
                                  <p class="col-sm-6 control-label">{{ b.Participant.user.email }}</p>
                                    {% endfor %}   
                                    </div>
                                           
                            </div>
                            <div class="modal-footer">
                                <button type="button" data-dismiss="modal" class="btn btn-raised btn-default">Cancel</button>
                            </div>
                        </div>
                    </div>
                </div>

                    </tr>

                {% else %}
                    <tr>
                        <td colspan="12">no records found</td>
                    </tr>
                {% endfor %}

            </table>
        </div>
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        $(document).ready(function() {
            $('#product-list').DataTable();
        } );
    </script>
{% endblock %}
