{% extends 'dashboard_screen/base.html' %}

{% block content %}

            <!-- ============================================================== -->
            <!-- Start right Content here -->
            <!-- ============================================================== -->
            <div class="content-page">
                <!-- Start content -->
                <div class="content">
                    <div class="container">
                        <div class="row">

                            <div class="col-lg-12">
                                 <!-- Basic Form Wizard -->

                            	<div class="card-box">
                            		<h4 class="m-t-0 header-title"><b>All Clients whit pending invoices</b></h4>
                                <div class="panel">
                                     <div class="form-group m-b-0">
                                         <div class="col-sm-offset-11 col-sm-11">
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-default dropdown-toggle waves-effect waves-light" data-toggle="dropdown" aria-expanded="false">{% if month == 1 %} January{% elif month == 2 %} February{% elif month == 3 %} March{% elif  month == 4 %} April{% elif month == 5 %} May{% elif month == 6 %} June{% elif month == 7 %} July{% elif month == 8 %} Agost{% elif month == 9 %} September{% elif month == 10 %} October{% elif month == 11 %} November{% elif month == 12 %} December{% endif %} <span class="caret"></span></button>
                                                    <ul class="dropdown-menu" role="menu">
                                                        <li><a href="/dashboard/billing/1/">January </a></li>
                                                        <li><a href="/dashboard/billing/2/">February </a></li>
                                                        <li><a href="/dashboard/billing/3/">March </a></li>
                                                        <li><a href="/dashboard/billing/4/">April </a></li>
                                                        <li><a href="/dashboard/billing/5/">May </a></li>
                                                        <li><a href="/dashboard/billing/6/">June </a></li>
                                                        <li><a href="/dashboard/billing/7/">July </a></li>
                                                        <li><a href="/dashboard/billing/8/">Agost </a></li>
                                                        <li><a href="/dashboard/billing/9/">September </a></li>
                                                        <li><a href="/dashboard/billing/10/">October </a></li>
                                                        <li><a href="/dashboard/billing/11/">November </a></li>
                                                        <li><a href="/dashboard/billing/12/">December </a></li>
                                                        <li><a href="#">Separated link</a></li>
                                                    </ul>
                                                </div>
                                         </div>
                                     </div>
                                   <br />
                                    {% if clients %}

                                        <div class="panel-body">


                                            <div class="">
                                	            <table id="datatable-responsive" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                                                    <thead>
                                                        <tr>
                                                            <th>Code11</th>
                                                            <th>Representative</th>
                                                            <th>Legal Name</th>
                                                            <th>Phone</th>
                                                            <th>Status</th>
                                                            <th>Actions</th>
                                                        </tr>
                                                    </thead>
	                                                <tbody>
                                                    {% for client in clients %}

                                                        {% if client.get_invoices %}
                                                          {% for Inv in client.get_invoices %}
                                                              {% if Inv.for_month == month %}
                                                                {{ Inv.invoice }}
                                                              {% endif %}
                                                          {% endfor %}
                                                        {% endif %}

                                                        {% if forloop.counter|divisibleby:2 %}
                                                            <tr class="gradeX">
                                                                <td>{{ client.client_code }}</td>
                                                                <td>{{ client.get_full_name }}</td>
                                                                <td>{{ client.business_legal_name }}</td>
                                                                <td>{{ client.business_phone }}</td>
                                                                <td>{% if not client.is_aproved or not client.has_price %} <span class="label label-warning">Pending</span>{% else %}<span class="label label-success">Aproved</span>{% endif %}</td>

                                                                <td class="actions">
                                                                    <a href="/dashboard/edit_client/{{ client.client_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                    <a href="/dashboard/invoice/{{ client.client_id }}/{{ month }}/" class="on-default remove-row"><i class="fa fa-institution"></i></a>
                                                                    <a href="/dashboard/update_client_price/{{ client.client_id }}/" class="on-default edit-row"><i class="fa fa-money"></i></a>
                                                                    {% if client.get_invoices %}
                                                                        {% for Inv in client.get_invoices %}
                                                                            {% if Inv.for_month == month %}
                                                                                <i class="fa fa-file-pdf-o"></i>
                                                                            {% endif %}
                                                                        {% endfor %}
                                                                    {% endif %}
                                                                </td>
                                                            </tr>
                                                        {% else %}
                                                            <tr class="gradeC">
                                                                <td>{{ client.client_code }}</td>
                                                                <td>{{ client.get_full_name }}</td>
                                                                <td>{{ client.business_legal_name }}</td>
                                                                <td>{{ client.business_phone }}</td>
                                                                <td>{% if not client.is_aproved or not client.has_price %} <span class="label label-warning">Pending</span>{% else %}<span class="label label-success">Aproved</span>{% endif %}</td>

                                                                <td class="actions">
                                                                    <a href="/dashboard/edit_client/{{ client.client_id }}/" class="on-default edit-row"><i class="fa fa-pencil"></i></a>
                                                                    <a href="/dashboard/invoice/{{ client.client_id }}/{{ month }}/" class="on-default remove-row"><i class="fa fa-institution"></i></a>
                                                                    <a href="/dashboard/update_client_price/{{ client.client_id }}/" class="on-default edit-row"><i class="fa fa-money"></i></a>
                                                                    {% if client.get_invoices %}
                                                                        {% for Inv in client.get_invoices %}
                                                                            {% if Inv.for_month == month %}
                                                                                <i class="fa fa-file-pdf-o"></i>
                                                                            {% endif %}
                                                                        {% endfor %}
                                                                    {% endif %}
                                                                </td>
                                                            </tr>
                                                        {% endif %}

                                                    {% endfor %}



                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                        <!-- end: page -->
                                    {% else %}
                                         <br />
                                            <h4 class="m-t-0 header-title"><b>There are not  Clients whit pending invoices</b></h4>
                                          <br />
                                    {% endif %}

                                </div> <!-- end Panel -->


                            </div>


                            <!-- End row -->

                            </div> <!-- end col -->
                        </div><!-- end row -->
                    </div> <!-- container -->

                </div> <!-- content -->


{% endblock %}