{% set userData = app.session.get('userData') %}
<form method="POST" id="form-patient_chart_update_is_done">
    <h5>{{ page_title }}</h5>
    <div id="flash-messages-content-modal"></div>
    <div class="row max-width-initial">
        <div class="large-12 columns">
            <div class="row">
                <div class="large-12 columns">
                    {{ form_label(form.id) }}
                    {{ form_widget(form.id) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.chartType) }}
                    {{ form_widget(form.chartType) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.chartStatus) }}
                    {{ form_widget(form.chartStatus) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.accountUserMoaAssignment) }}
                    {{ form_widget(form.accountUserMoaAssignment) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.internal_status) }}
                    {{ form_widget(form.internal_status) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.ticketUserAssignment) }}
                    {{ form_widget(form.ticketUserAssignment) }}
                </div>
                <div class="large-6 columns">
                    {{ form_label(form.ticketStatus) }}
                    {{ form_widget(form.ticketStatus) }}
                </div>
                <div class="large-6 columns">
                    {{ form_label(form.ticketSeverity) }}
                    {{ form_widget(form.ticketSeverity) }}
                </div>
                <div class="large-12 columns">
                    {{ form_label(form.note_type) }}
                    {{ form_widget(form.note_type) }}
                    <label class="note_template required middle hide" for="note_template_description">Note Template</label>
                    <input class="note_template hide" type="text" id="note_template_description">
                    <input type="hidden" id="note_template_id">
                    {{ form_label(form.note) }}
                    {{ form_widget(form.note) }}
                </div>
            </div>
            {% if patientNote ? patientNote|length > 0 %}
                <div class="row">
                    <div class="large-12 columns">
                        <div class="demo-box" style="height:auto; border:solid 2px #1eb7f0; padding-bottom:5px; margin-bottom: 15px;">
                            <h5 style="height:25px; font-size:12px; background-color:#2199e8; padding: 5px; color:#fff; font-family:'Arial';">Notes History</h5>
                            <div class="notes-history">
                                {% for pn in patientNote %}
                                    <div class="row">
                                        <div class="large-12 columns" style="margin-bottom: 5px; padding-left: 30px;">
                                            <b> {{ pn.createdBy|default('') }} [{{ pn.createdAt|date('m/d/Y H:i a')|default('') }}]</b> - {{ pn.note|default('') }}
                                        </div>
                                    </div>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                </div>
            {% endif %}
        </div>
    </div>
    <hr>
    <div class="row-max-width-initial">
        <div class="small-12 columns no-padding-right">
            <div class="button-container clearfix text-right">
                    <a href="javascript:void(0)" class="button just-continue href-update-is-done-action float-right" data-axn="{{ action }}"
                       data-message="Are you sure you want to save this information?"
                       style="margin-left: 10px; margin-right: 0;"
                    >Save</a>
                <a href="javascript:void(0)" class="button secondary" data-close style="margin-left: 10px; margin-right: 0;">Close</a>
            </div>
        </div>
    </div>
    {{ form_widget(form.action) }}
    {{ form_widget(form._token) }}
</form>
<script language="javascript">
    //<![CDATA[
    jQ('#patient_chart_update_is_done_internal_status').unbind('change').bind('change', function () {
        if(jQ(this).find('option:selected').text() === 'Endorsed'){
            jQ('.endorsed-remove').removeClass('hide');
        }else{
            jQ('.endorsed-remove').addClass('hide');
        }
    });
    if(jQ('#patient_chart_update_is_done_internal_status').find('option:selected').text() === 'Endorsed'){
        jQ('.endorsed-remove').removeClass('hide');
    }else{
        jQ('.endorsed-remove').addClass('hide');
    }
    let autoCompleteUrl = '{{ path('ticket_autocomplete') }}' ;
    let note_template_autoCompleteUrl = '{{ path('note_template_autocomplete') }}' ;
    let note_template_data_url = '{{ path('note_template_data') }}';
    jQ('#patient_chart_update_is_done_chartStatus').chained('#patient_chart_update_is_done_chartType');
    global.autocomplete.bind(autoCompleteUrl, '#patient_chart_update_is_done_ticketId', '#patient_chart_update_is_done_ticket');
    jQ('#patient_chart_update_is_done_note_type').unbind('change').bind('change', function () {
        if (jQ(this).val() == 'Template') {
            jQ('.note_template').removeClass('hide');
        } else {
            jQ('.note_template').addClass('hide');
        }
    });

    global.autocomplete.bind(note_template_autoCompleteUrl, '#note_template_description', '#note_template_id', {
        onSelect: function (d) {
            global.ajax({
                url: note_template_data_url+'/'+d.noteTemplate_description,
                type: 'GET',
                beforeSend: function() {
                    jQ('#patient_chart_update_is_done_note').val('');
                },
                success: function(json) {
                    jQ('#patient_chart_update_is_done_note').val(json.note);
                },
            });
        }
    });
    //]]>
</script>