{% extends 'base.html.twig' %}
{% block stylesheets %}
    <link rel="stylesheet" type="text/css" href="{{ asset('plugins/dropify/dropify.min.css') }}">
    <link href="{{ asset('assets/css/users/account-setting.css') }}" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="{{ asset('plugins/bootstrap-select/bootstrap-select.min.css') }}">
{% endblock %}
{% block body %}

    <div class="layout-px-spacing">
    <div class="page-header">
        <div class="page-title">
            <h3>Modification du Client</h3>
        </div>
    </div>
    <div class="row">
        <div class="col-lg-12 col-12  layout-spacing">
            <div class="statbox widget box box-shadow">
                <div class="widget-header">
                    <div class="row">
                        <div class="col-xl-12 col-md-12 col-sm-12 col-12">
                            <h4>
                                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
                                     fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                                     stroke-linejoin="round" class="feather feather-user text-info">
                                    <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
                                    <circle cx="12" cy="7" r="4"></circle>
                                </svg>
                                {{ client.email }}
                            </h4>
                        </div>
                    </div>
                </div>
                <div class="widget-content widget-content-area">
                    <form method="post" enctype="multipart/form-data">
                        <div class="row">
                            <div class="col-md-6">
                                <fieldset>
                                    <legend>Infos Entreprise : </legend>
                                <div class="form-group row mb-4">
                                    <label for="colFormLabelLg"
                                           class="col-sm-2 col-form-label col-form-label-lg">Entreprise</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control form-control-lg" name="company"
                                               value="{{ client.company }}">
                                    </div>
                                </div>
                                <div class="form-group row mb-4">
                                    <label for="colFormLabel" class="col-sm-2 col-form-label">Tél</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" name="tel" value="{{ client.tel }}">
                                    </div>
                                </div>

                                <div class="form-group row mb-4">
                                    <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">E-mail</label>
                                    <div class="col-sm-10">
                                        <input type="email" class="form-control form-control-sm" name="email" required
                                               value="{{ client.email }}">
                                    </div>
                                </div>
                                <div class="form-group row  mb-4">
                                    <label for="colFormLabel" class="col-sm-2 col-form-label">Logo</label>
                                    <div class="upload col-sm-10">
                                        <input type="file" name="logo" id="input-file-max-fs" class="dropify" data-default-file="{{ asset('uploads/clients/' ~ client.logo ) }}" alt="{{ client.logo  }}"
                                               data-max-file-size="2M"  />
                                    </div>
                                </div>
                                <div class="form-group row  mb-4">
                                    <label for="colFormLabelSm" class="col-sm-2 col-form-label col-form-label-sm">Password</label>
                                    <div class="col-sm-10">
                                        <input type="password" class="form-control form-control-sm" name="password"
                                        >
                                    </div>
                                </div>
                                </fieldset>
                            </div>
                            <div class="col-md-6">
                                <fieldset>
                                    <legend>Interlocuteur : </legend>
                                    <div class="row mb-4">
                                        <div class="col">
                                            <input type="text" name="interlocutorName" class="form-control" placeholder="Nom et prénom" value="{{ client.interlocutorName }}">
                                        </div>
                                    </div>
                                    <div class="row mb-4">
                                        <div class="col">
                                            <input type="email" name="interlocutorMail" class="form-control" placeholder="email" value="{{ client.interlocutorMail }}">
                                        </div>
                                    </div>
                                    <div class="row mb-4">
                                        <div class="col">
                                            <input type="text" name="interlocutorTel" class="form-control" placeholder="tel" value="{{ client.interlocutorTel }}">
                                        </div>
                                    </div>
                                </fieldset>
                                <fieldset>
                                    <legend>Représentant légale : </legend>
                                    {% if client.legalRepresentative is not null %}
                                        <div class="row mb-4">
                                            <div class="col-12" id="existingLegalRepresentative">
                                                <select class="selectpicker" data-live-search="true" data-width= "100%"
                                                        name="existingLegalRepresentative">
                                                    <option value="" selected disabled >Choisir le représentant légale...</option>
                                                    {% for legalRepresentative in legalRepresentatives %}
                                                        <option {% if legalRepresentative.id == client.legalRepresentative.id %} selected {% endif %}
                                                                value="{{ legalRepresentative.id }}">
                                                            {{ legalRepresentative.firstName }} {{ legalRepresentative.lastName }}
                                                        </option>
                                                    {% endfor %}
                                                </select>
                                            </div>
                                        </div>
                                    {% else %}
                                        <div id="legalRepresentativeForm">
                                            <div class="row mb-4">
                                                <div class="col">
                                                    <input type="text" name="newLegalRepresentativeFirstName" class="form-control" placeholder="Nom">
                                                </div>
                                            </div>
                                            <div class="row mb-4">
                                                <div class="col">
                                                    <input type="text" name="newLegalRepresentativeLastName" class="form-control" placeholder="Prénom">
                                                </div>
                                            </div>
                                            <div class="row mb-4">
                                                <div class="col">
                                                    <input type="email" name="newLegalRepresentativeMail" class="form-control" placeholder="Email">
                                                </div>
                                            </div>
                                            <div class="row mb-4">
                                                <div class="col">
                                                    <input type="text" name="newLegalRepresentativeTel" class="form-control" placeholder="tel">
                                                </div>
                                            </div>
                                        </div>
                                    {% endif %}
                                </fieldset>
                            </div>
                        </div>
                        <input type="submit" class="mb-4 btn btn-primary float-right">
                    </form>
                    <a href="{{ url('clients_management') }}" class="btn btn-outline-danger mb-2">Retour à la liste</a>
                </div>
            </div>
        </div>
    </div>
    </div>
</div>
{% endblock %}
{% block javascripts %}

    <script src="{{ asset('plugins/dropify/dropify.min.js') }}"></script>
    <script src="{{ asset('plugins/blockui/jquery.blockUI.min.js') }}"></script>
    <!-- <script src="plugins/tagInput/tags-input.js"></script> -->
    <script src="{{ asset('assets/js/users/account-settings.js') }}"></script>
    <script src="{{ asset('plugins/bootstrap-select/bootstrap-select.min.js') }}"></script>
{% endblock %}
