<?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/contrat/_popup_history_contrats.html.twig */
class __TwigTemplate_b808be20aa404e4e075dbd0c0123abb22f6a6a54fb07bba1d7a46362db105605 extends Template
{
    private $source;
    private $macros = [];

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

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

        $this->parent = false;

        $this->blocks = [
        ];
    }

    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/contrat/_popup_history_contrats.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/contrat/_popup_history_contrats.html.twig"));

        // line 1
        yield "<div id=\"popup-history-contrats-";
        yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, (isset($context["equipement"]) || array_key_exists("equipement", $context) ? $context["equipement"] : (function () { throw new RuntimeError('Variable "equipement" does not exist.', 1, $this->source); })()), "id", [], "any", false, false, false, 1), "html", null, true);
        yield "\" style=\"display:none\" >
    ";
        // line 2
        $context["sortedContrats"] = Twig\Extension\CoreExtension::sort($this->env, CoreExtension::getAttribute($this->env, $this->source, (isset($context["equipement"]) || array_key_exists("equipement", $context) ? $context["equipement"] : (function () { throw new RuntimeError('Variable "equipement" does not exist.', 2, $this->source); })()), "contrats", [], "any", false, false, false, 2), function ($__a__, $__b__) use ($context, $macros) { $context["a"] = $__a__; $context["b"] = $__b__; return (((1 === CoreExtension::compare(CoreExtension::getAttribute($this->env, $this->source, (isset($context["a"]) || array_key_exists("a", $context) ? $context["a"] : (function () { throw new RuntimeError('Variable "a" does not exist.', 2, $this->source); })()), "dateDebutContrat", [], "any", false, false, false, 2), CoreExtension::getAttribute($this->env, $this->source, (isset($context["b"]) || array_key_exists("b", $context) ? $context["b"] : (function () { throw new RuntimeError('Variable "b" does not exist.', 2, $this->source); })()), "dateDebutContrat", [], "any", false, false, false, 2)))) ? ( -1) : (1)); });
        // line 3
        yield "    ";
        $context["cles"] = Twig\Extension\CoreExtension::keys((isset($context["sortedContrats"]) || array_key_exists("sortedContrats", $context) ? $context["sortedContrats"] : (function () { throw new RuntimeError('Variable "sortedContrats" does not exist.', 3, $this->source); })()));
        // line 4
        yield "    <table class=\"table table-striped table-bordered\">
        <thead>
            <th>Date souscription</th>
            <th>Agent</th>
            <th>Date de contrat échue</th>
            <th>Date avis échéance</th>
            <th>Date relance 1</th>
            <th>Date relance 2</th>
            <th>Date paiement</th>
            <th>Mode paiement</th>
            <th>Montant HT</th>
            <th>TVA</th>
            <th>Montant TTC</th>
            <th>Coefficient</th>
        </thead>
        <tbody>
        ";
        // line 20
        $context["date_souscription"] = null;
        // line 21
        yield "        ";
        $context["date_contrat_echue"] = null;
        // line 22
        yield "            ";
        $context['_parent'] = $context;
        $context['_seq'] = CoreExtension::ensureTraversable((isset($context["sortedContrats"]) || array_key_exists("sortedContrats", $context) ? $context["sortedContrats"] : (function () { throw new RuntimeError('Variable "sortedContrats" does not exist.', 22, $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["contrat"]) {
            // line 23
            yield "                ";
            $context["date_souscription"] = ((((0 !== CoreExtension::compare((isset($context["date_souscription"]) || array_key_exists("date_souscription", $context) ? $context["date_souscription"] : (function () { throw new RuntimeError('Variable "date_souscription" does not exist.', 23, $this->source); })()), $this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "dateSouscription", [], "any", false, false, false, 23), "d/m/Y"))) || (null === (isset($context["date_souscription"]) || array_key_exists("date_souscription", $context) ? $context["date_souscription"] : (function () { throw new RuntimeError('Variable "date_souscription" does not exist.', 23, $this->source); })())))) ? ($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "dateSouscription", [], "any", false, false, false, 23), "d/m/Y")) : ("-"));
            // line 24
            yield "                ";
            $context["date_contrat_echue"] = (((-1 === CoreExtension::compare(CoreExtension::getAttribute($this->env, $this->source, $context["loop"], "index", [], "any", false, false, false, 24), Twig\Extension\CoreExtension::length($this->env->getCharset(), (isset($context["sortedContrats"]) || array_key_exists("sortedContrats", $context) ? $context["sortedContrats"] : (function () { throw new RuntimeError('Variable "sortedContrats" does not exist.', 24, $this->source); })()))))) ? ($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, (isset($context["sortedContrats"]) || array_key_exists("sortedContrats", $context) ? $context["sortedContrats"] : (function () { throw new RuntimeError('Variable "sortedContrats" does not exist.', 24, $this->source); })()), CoreExtension::getAttribute($this->env, $this->source, (isset($context["cles"]) || array_key_exists("cles", $context) ? $context["cles"] : (function () { throw new RuntimeError('Variable "cles" does not exist.', 24, $this->source); })()), CoreExtension::getAttribute($this->env, $this->source, $context["loop"], "index", [], "any", false, false, false, 24), [], "array", false, false, false, 24), [], "array", false, false, false, 24), "dateFinContrat", [], "any", false, false, false, 24), "d/m/Y")) : (""));
            // line 25
            yield "                <tr>
                    <td>";
            // line 26
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((isset($context["date_souscription"]) || array_key_exists("date_souscription", $context) ? $context["date_souscription"] : (function () { throw new RuntimeError('Variable "date_souscription" does not exist.', 26, $this->source); })()), "html", null, true);
            yield "</td>
                    <td>";
            // line 27
            ((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "agentSouscription", [], "any", false, false, false, 27)) ? (yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(((CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "agentSouscription", [], "any", false, false, false, 27), "id", [], "any", false, false, false, 27) . " - ") . CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "agent", [], "any", false, false, false, 27), "agentSouscription", [], "any", false, false, false, 27)), "html", null, true)) : (yield ""));
            yield "</td>
                    <td>";
            // line 28
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape((isset($context["date_contrat_echue"]) || array_key_exists("date_contrat_echue", $context) ? $context["date_contrat_echue"] : (function () { throw new RuntimeError('Variable "date_contrat_echue" does not exist.', 28, $this->source); })()), "html", null, true);
            yield "</td>
                    <td>";
            // line 29
            ((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "getDateAvisEcheance", [], "any", false, false, false, 29)) ? (yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "getDateAvisEcheance", [], "any", false, false, false, 29), "d/m/Y"), "html", null, true)) : (yield ""));
            yield "</td>
                    <td></td>
                    <td></td>
                    <td>";
            // line 32
            ((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "datePaiement", [], "any", false, false, false, 32)) ? (yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape($this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "datePaiement", [], "any", false, false, false, 32), "d/m/Y"), "html", null, true)) : (yield ""));
            yield "</td>
                    <td>";
            // line 33
            ((((((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33) && CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33), "paiements", [], "any", false, false, false, 33)) && (1 === CoreExtension::compare(Twig\Extension\CoreExtension::length($this->env->getCharset(), CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33), "paiements", [], "any", false, false, false, 33)), 0))) && CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33), "paiements", [], "any", false, false, false, 33), 0, [], "array", false, false, false, 33), "moyenPaiement", [], "any", false, false, false, 33)) && (1 === CoreExtension::compare(Twig\Extension\CoreExtension::length($this->env->getCharset(), CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33), "paiements", [], "any", false, false, false, 33), 0, [], "array", false, false, false, 33), "moyenPaiement", [], "any", false, false, false, 33)), 0)))) ? (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, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 33), "paiements", [], "any", false, false, false, 33), 0, [], "array", false, false, false, 33), "moyenPaiement", [], "any", false, false, false, 33), 0, [], "array", false, false, false, 33), "libelle_long", [], "any", false, false, false, 33), "html", null, true)) : (yield ""));
            yield "</td>
                    <td>";
            // line 34
            ((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 34)) ? (yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 34), "getMontantHt", [], "any", false, false, false, 34), "html", null, true)) : (yield ""));
            yield "</td>
                    <td></td>
                    <td>";
            // line 36
            ((CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 36)) ? (yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "facture", [], "any", false, false, false, 36), "getMontantTtc", [], "any", false, false, false, 36), "html", null, true)) : (yield ""));
            yield "</td>
                    <td>";
            // line 37
            yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "coefficient", [], "any", false, false, false, 37), "html", null, true);
            yield "</td>
                </tr>
                ";
            // line 39
            $context["date_souscription"] = $this->extensions['Twig\Extension\CoreExtension']->formatDate(CoreExtension::getAttribute($this->env, $this->source, $context["contrat"], "dateSouscription", [], "any", false, false, false, 39), "d/m/Y");
            // line 40
            yield "            ";
            ++$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['contrat'], $context['_parent'], $context['loop']);
        $context = array_intersect_key($context, $_parent) + $_parent;
        // line 41
        yield "            <tr></tr>
        </tbody>
    </table>

</div>";
        
        $__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e->leave($__internal_085b0142806202599c7fe3b329164a92397d8978207a37e79d70b8c52599e33e_prof);

        
        $__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02->leave($__internal_319393461309892924ff6e74d6d6e64287df64b63545b994e100d4ab223aed02_prof);

        return; yield '';
    }

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

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

    /**
     * @codeCoverageIgnore
     */
    public function getDebugInfo()
    {
        return array (  160 => 41,  146 => 40,  144 => 39,  139 => 37,  135 => 36,  130 => 34,  126 => 33,  122 => 32,  116 => 29,  112 => 28,  108 => 27,  104 => 26,  101 => 25,  98 => 24,  95 => 23,  77 => 22,  74 => 21,  72 => 20,  54 => 4,  51 => 3,  49 => 2,  44 => 1,);
    }

    public function getSourceContext()
    {
        return new Source("<div id=\"popup-history-contrats-{{ equipement.id }}\" style=\"display:none\" >
    {% set sortedContrats = equipement.contrats | sort((a, b) => a.dateDebutContrat > b.dateDebutContrat ? -1 : 1) %}
    {% set cles = sortedContrats|keys %}
    <table class=\"table table-striped table-bordered\">
        <thead>
            <th>Date souscription</th>
            <th>Agent</th>
            <th>Date de contrat échue</th>
            <th>Date avis échéance</th>
            <th>Date relance 1</th>
            <th>Date relance 2</th>
            <th>Date paiement</th>
            <th>Mode paiement</th>
            <th>Montant HT</th>
            <th>TVA</th>
            <th>Montant TTC</th>
            <th>Coefficient</th>
        </thead>
        <tbody>
        {% set date_souscription =  null %}
        {% set date_contrat_echue =  null %}
            {% for contrat in sortedContrats %}
                {% set date_souscription = (date_souscription != contrat.dateSouscription|date(\"d/m/Y\") or date_souscription is null) ? contrat.dateSouscription|date(\"d/m/Y\") : '-'  %}
                {% set date_contrat_echue = (loop.index) < sortedContrats|length ? sortedContrats[cles[loop.index]].dateFinContrat|date(\"d/m/Y\") : '' %}
                <tr>
                    <td>{{ date_souscription }}</td>
                    <td>{{ contrat.agentSouscription ? contrat.agentSouscription.id ~ ' - ' ~ contrat.agent.agentSouscription }}</td>
                    <td>{{ date_contrat_echue }}</td>
                    <td>{{  contrat.getDateAvisEcheance ? contrat.getDateAvisEcheance|date(\"d/m/Y\") }}</td>
                    <td></td>
                    <td></td>
                    <td>{{ contrat.datePaiement ? contrat.datePaiement|date(\"d/m/Y\") }}</td>
                    <td>{{ contrat.facture and contrat.facture.paiements and contrat.facture.paiements|length > 0 and contrat.facture.paiements[0].moyenPaiement and contrat.facture.paiements[0].moyenPaiement|length > 0 ? contrat.facture.paiements[0].moyenPaiement[0].libelle_long }}</td>
                    <td>{{ contrat.facture ? contrat.facture.getMontantHt }}</td>
                    <td></td>
                    <td>{{ contrat.facture ? contrat.facture.getMontantTtc }}</td>
                    <td>{{ contrat.coefficient }}</td>
                </tr>
                {% set date_souscription = contrat.dateSouscription|date(\"d/m/Y\")  %}
            {% endfor %}
            <tr></tr>
        </tbody>
    </table>

</div>", "clients/contrat/_popup_history_contrats.html.twig", "/builds/dev/refonte_sav/templates/clients/contrat/_popup_history_contrats.html.twig");
    }
}
