<?php

use Twig\Environment;
use Twig\Error\LoaderError;
use Twig\Error\RuntimeError;
use Twig\Extension\CoreExtension;
use Twig\Extension\SandboxExtension;
use Twig\Markup;
use Twig\Sandbox\SecurityError;
use Twig\Sandbox\SecurityNotAllowedTagError;
use Twig\Sandbox\SecurityNotAllowedFilterError;
use Twig\Sandbox\SecurityNotAllowedFunctionError;
use Twig\Source;
use Twig\Template;

/* clients/_popup_add_client.html.twig */
class __TwigTemplate_9de32d9edb4198a8cc713ae8fbabe3edc56b2a2759be01fd27ebf82a5d93328c extends Template
{
    private $source;
    private $macros = [];

    public function __construct(Environment $env)
    {
        parent::__construct($env);

        $this->source = $this->getSourceContext();

        $this->parent = false;

        $this->blocks = [
            'javascripts_body' => [$this, 'block_javascripts_body'],
        ];
    }

    protected function doDisplay(array $context, array $blocks = [])
    {
        $macros = $this->macros;
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "clients/_popup_add_client.html.twig"));

        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "template", "clients/_popup_add_client.html.twig"));

        // line 1
        yield "<div id=\"popup-add-client\" style=\"display:none;\" >
    <div class=\"px-4 pb-4 d-flex justify-content-center align-items-center flex-column\" style=\"width:auto\" >
        <div class=\"messages\" id=\"messages-popup-add-client\" style=\"width:100%\">
            <div class=\"alert alert-dismissible  fade show\"   role=\"alert\">
                <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\" style=\"opacity:1\"></button>
           </div>
        </div>
        <form id=\"form-add-client\"  class=\"form  mt-3 submit-add-utilisateur\" action=\"";
        // line 8
        yield $this->extensions['Symfony\Bridge\Twig\Extension\RoutingExtension']->getPath("nouveau_client");
        yield "\" method=\"post\"></form>
        <input type=\"hidden\" name=\"complements_adresse\" value=\"\" id=\"complements_adresse_hidden\" form=\"form-add-client\">
        <input type=\"hidden\" name=\"type_form_search\" value=\"utilisateur\" form=\"form-search-client\">
        <div>
            <div class=\"d-flex mb-3 pt-3\" style=\"border-top: 1px solid gray;\">
                ";
        // line 13
        $context["utilisateurSites"] = CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, (isset($context["app"]) || array_key_exists("app", $context) ? $context["app"] : (function () { throw new RuntimeError('Variable "app" does not exist.', 13, $this->source); })()), "user", [], "any", false, false, false, 13), "getUtilisateurSites", [], "any", false, false, false, 13);
        // line 14
        yield "                ";
        if ((1 === CoreExtension::compare(Twig\Extension\CoreExtension::length($this->env->getCharset(), (isset($context["utilisateurSites"]) || array_key_exists("utilisateurSites", $context) ? $context["utilisateurSites"] : (function () { throw new RuntimeError('Variable "utilisateurSites" does not exist.', 14, $this->source); })())), 1))) {
            // line 15
            yield "                    <div>
                        <div class=\"d-flex align-items-center me-5\">
                            <label style=\"width:40px;\" class=\"me-1\">Site </label>
                            <select name=\"site\" style=\"width:auto\" class=\"form-control\"  required form=\"form-add-client\">
                                ";
            // line 19
            $context['_parent'] = $context;
            $context['_seq'] = CoreExtension::ensureTraversable((isset($context["utilisateurSites"]) || array_key_exists("utilisateurSites", $context) ? $context["utilisateurSites"] : (function () { throw new RuntimeError('Variable "utilisateurSites" does not exist.', 19, $this->source); })()));
            foreach ($context['_seq'] as $context["_key"] => $context["utilisateurSite"]) {
                // line 20
                yield "                                    <option value=\"";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["utilisateurSite"], "site", [], "any", false, false, false, 20), "id", [], "any", false, false, false, 20), "html", null, true);
                yield "\">";
                yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["utilisateurSite"], "site", [], "any", false, false, false, 20), "nom", [], "any", false, false, false, 20), "html", null, true);
                yield "</option>
                                ";
            }
            $_parent = $context['_parent'];
            unset($context['_seq'], $context['_iterated'], $context['_key'], $context['utilisateurSite'], $context['_parent'], $context['loop']);
            $context = array_intersect_key($context, $_parent) + $_parent;
            // line 22
            yield "                            </select>
                        </div>
                    </div>
                ";
        } else {
            // line 26
            yield "                    <input name=\"site\" type=\"hidden\" value=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, (isset($context["utilisateurSites"]) || array_key_exists("utilisateurSites", $context) ? $context["utilisateurSites"] : (function () { throw new RuntimeError('Variable "utilisateurSites" does not exist.', 26, $this->source); })()), 0, [], "array", false, false, false, 26), "getSite", [], "any", false, false, false, 26), "id", [], "any", false, false, false, 26), "html", null, true);
            yield "\" form=\"form-add-client\" >
                ";
        }
        // line 28
        yield "                <div class=\"input-group\" style=\"width: auto;\">
                    <label class=\"me-2 col-form-label control-label\">Type</label>
                    <select name=\"type_client\" id=\"type_client\" style=\"width: 150px !important;flex: 0 1 auto;\" class=\"form-control\" form=\"form-add-client\"
                            onchange=\"if (\$(this).val() == '1') {\$('.infos-entreprise').hide();\$('.infos-client').css('display','flex');} else {
                                    \$('.infos-entreprise').css('display','flex');\$('.infos-client').hide();}\"
                    >
                        ";
        // line 34
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable((isset($context["typesClientAll"]) || array_key_exists("typesClientAll", $context) ? $context["typesClientAll"] : (function () { throw new RuntimeError('Variable "typesClientAll" does not exist.', 34, $this->source); })()));
        $context['loop'] = [
          'parent' => $context['_parent'],
          'index0' => 0,
          'index'  => 1,
          'first'  => true,
        ];
        if (is_array($context['_seq']) || (is_object($context['_seq']) && $context['_seq'] instanceof \Countable)) {
            $length = count($context['_seq']);
            $context['loop']['revindex0'] = $length - 1;
            $context['loop']['revindex'] = $length;
            $context['loop']['length'] = $length;
            $context['loop']['last'] = 1 === $length;
        }
        foreach ($context['_seq'] as $context["_key"] => $context["type"]) {
            // line 35
            yield "                            <option ";
            yield (((0 === CoreExtension::compare(CoreExtension::getAttribute($this->env, $this->source, $context["loop"], "index", [], "any", false, false, false, 35), 1))) ? ("selected") : (""));
            yield " value=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["type"], "id", [], "any", false, false, false, 35), "html", null, true);
            yield "\">";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["type"], "libelle", [], "any", false, false, false, 35), "html", null, true);
            yield "</option>
                        ";
            ++$context['loop']['index0'];
            ++$context['loop']['index'];
            $context['loop']['first'] = false;
            if (isset($context['loop']['length'])) {
                --$context['loop']['revindex0'];
                --$context['loop']['revindex'];
                $context['loop']['last'] = 0 === $context['loop']['revindex0'];
            }
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['type'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 37
        yield "                    </select>
                </div>
            </div>
            <div class=\"\">
                <div class=\"d-flex my-3 pt-3 justify-content-between\">
                    <div class=\"infos-entreprise me-3\" style=\"display: none;\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\">Catégorie</label>
                            <select name=\"categorie_pro\" class=\"form-control\" id=\"categorie_pro\" style=\"width: 150px !important;flex: 0 1 auto;\" form=\"form-add-client\">
                                <option value=\"\">Sélectionnez [...]</option>
                                ";
        // line 47
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable((isset($context["categoriesPro"]) || array_key_exists("categoriesPro", $context) ? $context["categoriesPro"] : (function () { throw new RuntimeError('Variable "categoriesPro" does not exist.', 47, $this->source); })()));
        foreach ($context['_seq'] as $context["_key"] => $context["categorie_p"]) {
            // line 48
            yield "                                    <option value=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["categorie_p"], "id", [], "any", false, false, false, 48), "html", null, true);
            yield "\">";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["categorie_p"], "libelle", [], "any", false, false, false, 48), "html", null, true);
            yield "</option>
                                ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['categorie_p'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 50
        yield "                            </select>
                        </div>
                    </div>
                    <div class=\"infos-entreprise \" style=\"display: none;\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"client_entreprise\">Nom entreprise</label>
                            <input type=\"text\" id=\"client_entreprise\" name=\"client_entreprise\" class=\"form-control bg-white\" form=\"form-add-client\">
                        </div>
                    </div>
                    <div class=\"col-2 w-auto me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\">Civilité</label>
                            <select name=\"etat_civil\" class=\"form-control\" style=\"width: 90px !important;flex: 0 1 auto;\" form=\"form-add-client\">
                                ";
        // line 63
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable((isset($context["civilites"]) || array_key_exists("civilites", $context) ? $context["civilites"] : (function () { throw new RuntimeError('Variable "civilites" does not exist.', 63, $this->source); })()));
        foreach ($context['_seq'] as $context["_key"] => $context["civilite"]) {
            // line 64
            yield "                                    <option value=\"";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["civilite"], "id", [], "any", false, false, false, 64), "html", null, true);
            yield "\">";
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["civilite"], "libelleCourt", [], "any", false, false, false, 64), "html", null, true);
            yield "</option>
                                ";
        }
        $_parent = $context['_parent'];
        unset($context['_seq'], $context['_iterated'], $context['_key'], $context['civilite'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 66
        yield "                            </select>
                        </div>
                    </div>
                    <div class=\"me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"agent_nom\">Nom</label>
                            <input type=\"text\" name=\"client_nom\" id=\"client_nom\"  class=\"form-control bg-white\" value=\"\" form=\"form-add-client\">
                        </div>
                    </div>
                    <div class=\"me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"agent_prenom\">Prénom</label>

                            <input type=\"text\" name=\"client_prenom\" id=\"client_prenom\" class=\"form-control bg-white\" value=\"\" form=\"form-add-client\">
                        </div>
                    </div>
                </div>
                <div class=\"input-group form-group\">
                    <label class=\"me-2 col-form-label control-label\" >Adresse</label>
                    <input type=\"text\" name=\"adresse\" data-diverror=\"#client_adresse_error\" data-prefix=\"client\" style=\"width: 490px;flex:initial;\"  class=\"form-control bg-white input-field adresse_auto\" data-idsite=\"";
        // line 85
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, (isset($context["utilisateurSites"]) || array_key_exists("utilisateurSites", $context) ? $context["utilisateurSites"] : (function () { throw new RuntimeError('Variable "utilisateurSites" does not exist.', 85, $this->source); })()), 0, [], "array", false, false, false, 85), "site", [], "any", false, false, false, 85), "id", [], "any", false, false, false, 85), "html", null, true);
        yield "\" value=\"\" form=\"form-add-client\">
                    <button id=\"addresse_non_trouvee\" class=\"btn btn-primary\">Adresse non trouvée?</button><br>

                </div>
                <div class=\"adresse_auto_error\" id=\"client_adresse_error\" style=\"display: none;height:30px;margin-bottom:0\"></div>
                <small id=\"adresseHelp\" class=\"form-text text-muted\">Si  votre adresse n'est pas retrouvée, recherchez un numéro proche du client pour obtenir ses coordonnées gps, puis appuyez sur \"Adresse non trouvée\".</small>
                <div class=\"input-group form-group mt-2\" style=\"max-width: 850px;\">
                    <input type=\"hidden\" required name=\"client_adresse\" title=\"adresse\" id=\"client_adresse\" style=\"width:250px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"numero, rue\"  form=\"form-add-client\">
                    <input type=\"hidden\" required name=\"client_code_postal\" title=\"code_postal\"  style=\"width:130px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"code postal\" id=\"client_code_postal\" form=\"form-add-client\" readonly>
                    <input type=\"hidden\" required name=\"client_ville\" title=\"ville\" id=\"client_ville\" style=\"width:230px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"ville\"  form=\"form-add-client\" readonly>
                    <input type=\"hidden\" required name=\"client_coordinates\" title=\"coordonnees_gps\" form=\"form-add-client\" placeholder=\"coordonnées GPS\" class=\"element_adresse_non_trouvee form-control\" style=\"width:200px;flex:initial;\" readonly>
                </div>
                <div class=\"form-check mt-1\">
                    <input class=\"form-check-input\" type=\"checkbox\" name=\"meme_adresse_equipement\" value=\"1\" id=\"check_meme_adresse_equipement\" form=\"form-add-client\">
                    <label class=\"form-check-label\" for=\"check_meme_adresse_equipement\">
                        même adresse pour l'équipement
                    </label>
                </div>
                <div class=\"mt-1\" style=\"display: none;width:730px;\" id=\"add_client_complement_adresse\">
                    <div>Compléments d'adresse</div>
                    <div class=\"d-flex \" style=\"position: absolute;top:inherit;right:10px;\">
                        <i  class=\"fa fa-lg fa-plus custom-history bg-vert add_complement_adresse\" data-target-grid=\"#complement-adresse-grid-0\" style=\"position:relative;border-color: #14a085 !important;-webkit-text-stroke: 1px #14a085;top:inherit;right:inherit\"></i>
                    </div>
                    <div
                            style=\"padding-right: 38px;\"
                            class=\"grid grid-condensed\"
                            data-style=\"tab\"
                            id=\"complement-adresse-grid-0\"
                            data-page=\"AdresseComplement\"
                           data-columns=\"";
        // line 114
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(json_encode(CoreExtension::getAttribute($this->env, $this->source, (isset($context["complementAdresseGrid"]) || array_key_exists("complementAdresseGrid", $context) ? $context["complementAdresseGrid"] : (function () { throw new RuntimeError('Variable "complementAdresseGrid" does not exist.', 114, $this->source); })()), "columns", [], "any", false, false, false, 114)), "html", null, true);
        yield "\"
                            data-source=\"{}\"
                            data-searchpanel='{\"visible\":false}'
                            data-pagination='{\"visible\":false}'
                            data-toolbarinvisible=\"true\"
                    >
                    </div>
                </div>
            </div>
        </div>
        <div class=\"form-group d-flex justify-content-center mt-4\" >
            <div class=\"form-actions-row\">
                <button  id=\"verif_client\" class=\"btn btn-success me-3 \" >Vérifier le client</button>
                <button  id=\"submit-add-client\" class=\"btn btn-success me-3 \" type=\"submit\" disabled form=\"form-add-client\">Ajouter</button>
                <button  class=\"btn btn-danger btn-close-popup\"  data-dxpopup-id=\"popup-add-client\" type=\"button\" >Fermer</button>
            </div>
        </div>
    </div>
</div>

";
        // line 134
        yield from $this->unwrap()->yieldBlock('javascripts_body', $context, $blocks);
        
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);

        
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);

        return; yield '';
    }

    public function block_javascripts_body($context, array $blocks = [])
    {
        $macros = $this->macros;
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e = $this->extensions["Symfony\\Bundle\\WebProfilerBundle\\Twig\\WebProfilerExtension"];
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->enter($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts_body"));

        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02 = $this->extensions["Symfony\\Bridge\\Twig\\Extension\\ProfilerExtension"];
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->enter($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof = new \Twig\Profiler\Profile($this->getTemplateName(), "block", "javascripts_body"));

        // line 135
        yield "    <script type=\"module\">
        \$('body').on('click', '.add_complement_adresse', function (e) {
            var targetGrid = \$(\$(this).data('target-grid')).dxDataGrid('instance');
            targetGrid.addRow();
        });
        \$('body').on('click','#addresse_non_trouvee', function(e) {
            \$('.element_adresse_non_trouvee').attr('type', 'text');
        });
        \$('body').on('click', '#submit-add-client', function(e) {
           if (\$(this).prop('disabled') == false) {
               var grid = \$('#complement-adresse-grid-0').dxDataGrid('instance');
               \$('#complements_adresse_hidden').val(JSON.stringify(Object.assign({},grid.getDataSource().items())));
               \$('#form-add-client')[0].submit();
           }
        });
        \$('body').on('change','#check_meme_adresse_equipement', function(e) {
           if(\$(this).is(':checked')) \$('#add_client_complement_adresse').show();
           else \$('#add_client_complement_adresse').hide();
        })
        \$('body').on('click', '#verif_client', function(e) {
            \$.ajax({
                method: \"POST\",
                url:  '/clients/verif_doublon',
                data: {\"adresse\": \$('#client_adresse').val(), \"code_postal\": \$('#client_code_postal').val(),
                \"ville\": \$('#client_ville').val(), \"prenom\": \$('#client_prenom').val(), \"nom\": \$('#client_nom').val(), \"entreprise\":\$('#client_entreprise').val(),
                    \"type\":\$('#type_client').val(), \"categorie_pro\" : \$('#categorie_pro').val()},
                dataType: \"json\",
                success: function(data){
                    \$('#messages-popup-add-client').show();
                    var child = \$('#messages-popup-add-client').children()[0];
                    \$(child).removeClass('alert-danger').removeClass('alert-success');
                    \$(child).text(data.message);
                    \$(child).addClass('alert-' + data.type);
                    \$(child).show();
                    if (data.type == 'success') {
                        \$('#submit-add-client').removeAttr('disabled');
                        \$('#submit-add-client').prop('disabled',false);
                    } else {
                        \$('#submit-add-client').attr('disabled');
                        \$('#submit-add-client').prop('disabled',true);
                    }
                }
            })
        })
    </script>
";
        
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);

        
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);

        return; yield '';
    }

    /**
     * @codeCoverageIgnore
     */
    public function getTemplateName()
    {
        return "clients/_popup_add_client.html.twig";
    }

    /**
     * @codeCoverageIgnore
     */
    public function isTraitable()
    {
        return false;
    }

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  299 => 135,  279 => 134,  256 => 114,  224 => 85,  203 => 66,  192 => 64,  188 => 63,  173 => 50,  162 => 48,  158 => 47,  146 => 37,  125 => 35,  108 => 34,  100 => 28,  94 => 26,  88 => 22,  77 => 20,  73 => 19,  67 => 15,  64 => 14,  62 => 13,  54 => 8,  45 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("<div id=\"popup-add-client\" style=\"display:none;\" >
    <div class=\"px-4 pb-4 d-flex justify-content-center align-items-center flex-column\" style=\"width:auto\" >
        <div class=\"messages\" id=\"messages-popup-add-client\" style=\"width:100%\">
            <div class=\"alert alert-dismissible  fade show\"   role=\"alert\">
                <button type=\"button\" class=\"btn-close\" data-bs-dismiss=\"alert\" aria-label=\"Close\" style=\"opacity:1\"></button>
           </div>
        </div>
        <form id=\"form-add-client\"  class=\"form  mt-3 submit-add-utilisateur\" action=\"{{ path('nouveau_client') }}\" method=\"post\"></form>
        <input type=\"hidden\" name=\"complements_adresse\" value=\"\" id=\"complements_adresse_hidden\" form=\"form-add-client\">
        <input type=\"hidden\" name=\"type_form_search\" value=\"utilisateur\" form=\"form-search-client\">
        <div>
            <div class=\"d-flex mb-3 pt-3\" style=\"border-top: 1px solid gray;\">
                {% set utilisateurSites = app.user.getUtilisateurSites %}
                {% if utilisateurSites|length > 1 %}
                    <div>
                        <div class=\"d-flex align-items-center me-5\">
                            <label style=\"width:40px;\" class=\"me-1\">Site </label>
                            <select name=\"site\" style=\"width:auto\" class=\"form-control\"  required form=\"form-add-client\">
                                {% for utilisateurSite in utilisateurSites %}
                                    <option value=\"{{ utilisateurSite.site.id }}\">{{ utilisateurSite.site.nom }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                {% else %}
                    <input name=\"site\" type=\"hidden\" value=\"{{ utilisateurSites[0].getSite.id }}\" form=\"form-add-client\" >
                {% endif %}
                <div class=\"input-group\" style=\"width: auto;\">
                    <label class=\"me-2 col-form-label control-label\">Type</label>
                    <select name=\"type_client\" id=\"type_client\" style=\"width: 150px !important;flex: 0 1 auto;\" class=\"form-control\" form=\"form-add-client\"
                            onchange=\"if (\$(this).val() == '1') {\$('.infos-entreprise').hide();\$('.infos-client').css('display','flex');} else {
                                    \$('.infos-entreprise').css('display','flex');\$('.infos-client').hide();}\"
                    >
                        {% for type in typesClientAll %}
                            <option {{ loop.index == 1 ? 'selected' : '' }} value=\"{{ type.id }}\">{{ type.libelle }}</option>
                        {% endfor %}
                    </select>
                </div>
            </div>
            <div class=\"\">
                <div class=\"d-flex my-3 pt-3 justify-content-between\">
                    <div class=\"infos-entreprise me-3\" style=\"display: none;\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\">Catégorie</label>
                            <select name=\"categorie_pro\" class=\"form-control\" id=\"categorie_pro\" style=\"width: 150px !important;flex: 0 1 auto;\" form=\"form-add-client\">
                                <option value=\"\">Sélectionnez [...]</option>
                                {% for categorie_p in categoriesPro %}
                                    <option value=\"{{ categorie_p.id }}\">{{ categorie_p.libelle }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class=\"infos-entreprise \" style=\"display: none;\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"client_entreprise\">Nom entreprise</label>
                            <input type=\"text\" id=\"client_entreprise\" name=\"client_entreprise\" class=\"form-control bg-white\" form=\"form-add-client\">
                        </div>
                    </div>
                    <div class=\"col-2 w-auto me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\">Civilité</label>
                            <select name=\"etat_civil\" class=\"form-control\" style=\"width: 90px !important;flex: 0 1 auto;\" form=\"form-add-client\">
                                {% for civilite in civilites %}
                                    <option value=\"{{ civilite.id }}\">{{ civilite.libelleCourt }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class=\"me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"agent_nom\">Nom</label>
                            <input type=\"text\" name=\"client_nom\" id=\"client_nom\"  class=\"form-control bg-white\" value=\"\" form=\"form-add-client\">
                        </div>
                    </div>
                    <div class=\"me-3 infos-client\">
                        <div class=\"input-group form-group\">
                            <label class=\"me-2 col-form-label control-label\" for=\"agent_prenom\">Prénom</label>

                            <input type=\"text\" name=\"client_prenom\" id=\"client_prenom\" class=\"form-control bg-white\" value=\"\" form=\"form-add-client\">
                        </div>
                    </div>
                </div>
                <div class=\"input-group form-group\">
                    <label class=\"me-2 col-form-label control-label\" >Adresse</label>
                    <input type=\"text\" name=\"adresse\" data-diverror=\"#client_adresse_error\" data-prefix=\"client\" style=\"width: 490px;flex:initial;\"  class=\"form-control bg-white input-field adresse_auto\" data-idsite=\"{{ utilisateurSites[0].site.id }}\" value=\"\" form=\"form-add-client\">
                    <button id=\"addresse_non_trouvee\" class=\"btn btn-primary\">Adresse non trouvée?</button><br>

                </div>
                <div class=\"adresse_auto_error\" id=\"client_adresse_error\" style=\"display: none;height:30px;margin-bottom:0\"></div>
                <small id=\"adresseHelp\" class=\"form-text text-muted\">Si  votre adresse n'est pas retrouvée, recherchez un numéro proche du client pour obtenir ses coordonnées gps, puis appuyez sur \"Adresse non trouvée\".</small>
                <div class=\"input-group form-group mt-2\" style=\"max-width: 850px;\">
                    <input type=\"hidden\" required name=\"client_adresse\" title=\"adresse\" id=\"client_adresse\" style=\"width:250px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"numero, rue\"  form=\"form-add-client\">
                    <input type=\"hidden\" required name=\"client_code_postal\" title=\"code_postal\"  style=\"width:130px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"code postal\" id=\"client_code_postal\" form=\"form-add-client\" readonly>
                    <input type=\"hidden\" required name=\"client_ville\" title=\"ville\" id=\"client_ville\" style=\"width:230px;flex:initial;\" class=\"element_adresse_non_trouvee form-control me-2\" placeholder=\"ville\"  form=\"form-add-client\" readonly>
                    <input type=\"hidden\" required name=\"client_coordinates\" title=\"coordonnees_gps\" form=\"form-add-client\" placeholder=\"coordonnées GPS\" class=\"element_adresse_non_trouvee form-control\" style=\"width:200px;flex:initial;\" readonly>
                </div>
                <div class=\"form-check mt-1\">
                    <input class=\"form-check-input\" type=\"checkbox\" name=\"meme_adresse_equipement\" value=\"1\" id=\"check_meme_adresse_equipement\" form=\"form-add-client\">
                    <label class=\"form-check-label\" for=\"check_meme_adresse_equipement\">
                        même adresse pour l'équipement
                    </label>
                </div>
                <div class=\"mt-1\" style=\"display: none;width:730px;\" id=\"add_client_complement_adresse\">
                    <div>Compléments d'adresse</div>
                    <div class=\"d-flex \" style=\"position: absolute;top:inherit;right:10px;\">
                        <i  class=\"fa fa-lg fa-plus custom-history bg-vert add_complement_adresse\" data-target-grid=\"#complement-adresse-grid-0\" style=\"position:relative;border-color: #14a085 !important;-webkit-text-stroke: 1px #14a085;top:inherit;right:inherit\"></i>
                    </div>
                    <div
                            style=\"padding-right: 38px;\"
                            class=\"grid grid-condensed\"
                            data-style=\"tab\"
                            id=\"complement-adresse-grid-0\"
                            data-page=\"AdresseComplement\"
                           data-columns=\"{{ complementAdresseGrid.columns|json_encode() }}\"
                            data-source=\"{}\"
                            data-searchpanel='{\"visible\":false}'
                            data-pagination='{\"visible\":false}'
                            data-toolbarinvisible=\"true\"
                    >
                    </div>
                </div>
            </div>
        </div>
        <div class=\"form-group d-flex justify-content-center mt-4\" >
            <div class=\"form-actions-row\">
                <button  id=\"verif_client\" class=\"btn btn-success me-3 \" >Vérifier le client</button>
                <button  id=\"submit-add-client\" class=\"btn btn-success me-3 \" type=\"submit\" disabled form=\"form-add-client\">Ajouter</button>
                <button  class=\"btn btn-danger btn-close-popup\"  data-dxpopup-id=\"popup-add-client\" type=\"button\" >Fermer</button>
            </div>
        </div>
    </div>
</div>

{% block javascripts_body %}
    <script type=\"module\">
        \$('body').on('click', '.add_complement_adresse', function (e) {
            var targetGrid = \$(\$(this).data('target-grid')).dxDataGrid('instance');
            targetGrid.addRow();
        });
        \$('body').on('click','#addresse_non_trouvee', function(e) {
            \$('.element_adresse_non_trouvee').attr('type', 'text');
        });
        \$('body').on('click', '#submit-add-client', function(e) {
           if (\$(this).prop('disabled') == false) {
               var grid = \$('#complement-adresse-grid-0').dxDataGrid('instance');
               \$('#complements_adresse_hidden').val(JSON.stringify(Object.assign({},grid.getDataSource().items())));
               \$('#form-add-client')[0].submit();
           }
        });
        \$('body').on('change','#check_meme_adresse_equipement', function(e) {
           if(\$(this).is(':checked')) \$('#add_client_complement_adresse').show();
           else \$('#add_client_complement_adresse').hide();
        })
        \$('body').on('click', '#verif_client', function(e) {
            \$.ajax({
                method: \"POST\",
                url:  '/clients/verif_doublon',
                data: {\"adresse\": \$('#client_adresse').val(), \"code_postal\": \$('#client_code_postal').val(),
                \"ville\": \$('#client_ville').val(), \"prenom\": \$('#client_prenom').val(), \"nom\": \$('#client_nom').val(), \"entreprise\":\$('#client_entreprise').val(),
                    \"type\":\$('#type_client').val(), \"categorie_pro\" : \$('#categorie_pro').val()},
                dataType: \"json\",
                success: function(data){
                    \$('#messages-popup-add-client').show();
                    var child = \$('#messages-popup-add-client').children()[0];
                    \$(child).removeClass('alert-danger').removeClass('alert-success');
                    \$(child).text(data.message);
                    \$(child).addClass('alert-' + data.type);
                    \$(child).show();
                    if (data.type == 'success') {
                        \$('#submit-add-client').removeAttr('disabled');
                        \$('#submit-add-client').prop('disabled',false);
                    } else {
                        \$('#submit-add-client').attr('disabled');
                        \$('#submit-add-client').prop('disabled',true);
                    }
                }
            })
        })
    </script>
{% endblock %}", "clients/_popup_add_client.html.twig", "/builds/dev/refonte_sav/templates/clients/_popup_add_client.html.twig");
    }
}
