{{!
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template mod_booking/certificateconditionslist

    Classes required for JS:
    * none

    Data attributes required for JS:
    * data-region

    Example context (json):
    {
        "conditions" : [
            {
                "id": 1,
                "name" : "Condition name",
                "contextid": 1,
                "filtername" : "filtername",
                "logicname" : "logicname",
                "actionname" : "actionname",
                "localizedfiltername" : "localizedfiltername",
                "localizedlogicname" : "localizedlogicname",
                "localizedactionname" : "localizedactionname"
            }
        ],
        "contextid": 1
    }
}}

<div class="booking-rules-container">
    {{#enableaddbutton}}
        <div class="btn btn-success booking-rules-addnewrulebtn" data-action="edit-or-new" data-id="0" data-contextid="{{contextid}}" data-certificate="1">
            <i class="fa fa-plus-square" aria-hidden="true"></i>&nbsp;{{#str}} addcertificatecondition, mod_booking {{/str}}
        </div>
    {{/enableaddbutton}}
    {{^enableaddbutton}}
        <div class="alert alert-warning">
            {{#str}} useprotoenablemorecertificateconditions, mod_booking {{/str}}
        </div>
    {{/enableaddbutton}}
    <ul class="mt-3 list-group booking-rules-list">
        {{#conditions}}
        <li class="list-group-item {{#isactive}}ruleactive{{/isactive}} {{^isactive}}ruleinactive{{/isactive}}">
            <div class="d-flex justify-content-between">
                <h5>
                    {{name}}
                </h5>
                <div class="btn-group" role="group" aria-label="Certificate condition buttons">
                    <div class="btn btn-sm btn-outline-danger" data-action="delete" data-id="{{id}}" data-name="{{name}}" data-contextid="{{contextid}}" data-certificate="1">
                        <i class="fa fa-trash" aria-hidden="true"></i> {{#str}} delete {{/str}}
                    </div>
                    <div class="btn btn-sm btn-outline-primary" data-action="edit-or-new" data-id="{{id}}" data-name="{{name}}" data-contextid="{{contextid}}" data-certificate="1">
                        <i class="fa fa-pencil" aria-hidden="true"></i> {{#str}} edit {{/str}}
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small>
                            {{#isactive}}<i class="fa fa-check" aria-hidden="true"></i> {{/isactive}}
                            {{^isactive}}<i class="fa fa-ban" aria-hidden="true"></i> {{/isactive}}
                        </small>
                    </div>
                    <div class="col-sm-11">
                        <small>
                            {{#isactive}} {{#str}} certificateconditionisactive, mod_booking {{/str}} {{/isactive}}
                            {{^isactive}} {{#str}} certificateconditionisnotactive, mod_booking {{/str}} {{/isactive}}
                        </small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-list-ul" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedfiltername}}</small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-random" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedlogicname}}</small>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-1 text-right">
                        <small><i class="fa fa-play" aria-hidden="true"></i></small>
                    </div>
                    <div class="col-sm-11">
                        <small>{{localizedactionname}}</small>
                    </div>
                </div>
            </div>
        </li>
        {{/conditions}}
    </ul>
    {{#displayothercontexts}}
        <div class="mt-4">
            <h5 class="mb-3">{{#str}} certificateconditionsothercontextheading, mod_booking {{/str}}</h5>
            {{#conditionsothercontext}}
                <div>
                    <a href="{{linktoconditionsininstance}}" target="_blank">
                        <i class="fa fa-fw fa-graduation-cap" aria-hidden="true"></i>
                        {{coursename}}
                        <i class="fa fa-fw fa-calendar-check-o" aria-hidden="true"></i>
                        {{bookingname}}
                    </a>
                </div>
            {{/conditionsothercontext}}
            {{^conditionsothercontext}}
                <div>{{#str}} certificateconditionsnootherfound, mod_booking {{/str}}</div>
            {{/conditionsothercontext}}
        </div>
    {{/displayothercontexts}}
</div>