<commit_before>{% extends 'layout/dialog.html' %}
{% import 'macros.twig' as scat %}

{% block title %}
  Email {{ txn.type == 'vendor' ? 'PO' : 'Invoice' }} {{ txn.formatted_number }}
{% endblock %}

{% block body %}
  <div class="modal-body">

    <div class="form-group">
      <label for="name">Email</label>
      <input type="text" class="form-control" autofocus
             name="email" value="{{ txn.person.email }}">
    </div>

    <div class="form-group">
      <label for="name">Name</label>
      <input type="text" class="form-control"
             name="name" value="{{ txn.person.name }}">
    </div>

    <div class="form-group">
      <label for="name">Subject</label>
      <input type="text" class="form-control"
             name="subject"
             value="{{ txn.person.company }} {{ (txn.type == 'vendor') ? 'PO' : 'Invoice' }} {{ txn.formatted_number }}">
    </div>

    <div class="form-group">
      <label for="description">Content</label>
      <textarea class="form-control" rows="10" name="content"></textarea>
    </div>

    <div class="form-group">
      <div class="checkbox">
        <label>
          <input type="checkbox" value="1" name="include_details" checked>
          Include {{ txn.type == 'vendor' ? 'Purchase Order' : 'Invoice' }} PDF
        </label>
      </div>
    </div>

  </div>
{% endblock %}

{% block submit %}
  <button type="submit" class="btn btn-primary">
    Send
  </a>
{% endblock %}

{% block script %}
  form.onsubmit= (event) => {
    event.preventDefault()

    let form= dialog.getElementsByTagName('form')[0]
    let formData= new FormData(form)
    scat.call("/sale/{{ txn.id }}/email-invoice", formData)
    .then((res) => res.json())
    .then((data) => {
      alert(data.message)
      $(dialog).modal('hide')
    })
  }
{% endblock %}<commit_msg>Use scat.alert after email sent<commit_after>{% extends 'layout/dialog.html' %}
{% import 'macros.twig' as scat %}

{% block title %}
  Email {{ txn.type == 'vendor' ? 'PO' : 'Invoice' }} {{ txn.formatted_number }}
{% endblock %}

{% block body %}
  <div class="modal-body">

    <div class="form-group">
      <label for="name">Email</label>
      <input type="text" class="form-control" autofocus
             name="email" value="{{ txn.person.email }}">
    </div>

    <div class="form-group">
      <label for="name">Name</label>
      <input type="text" class="form-control"
             name="name" value="{{ txn.person.name }}">
    </div>

    <div class="form-group">
      <label for="name">Subject</label>
      <input type="text" class="form-control"
             name="subject"
             value="{{ txn.person.company }} {{ (txn.type == 'vendor') ? 'PO' : 'Invoice' }} {{ txn.formatted_number }}">
    </div>

    <div class="form-group">
      <label for="description">Content</label>
      <textarea class="form-control" rows="10" name="content"></textarea>
    </div>

    <div class="form-group">
      <div class="checkbox">
        <label>
          <input type="checkbox" value="1" name="include_details" checked>
          Include {{ txn.type == 'vendor' ? 'Purchase Order' : 'Invoice' }} PDF
        </label>
      </div>
    </div>

  </div>
{% endblock %}

{% block submit %}
  <button type="submit" class="btn btn-primary">
    Send
  </a>
{% endblock %}

{% block script %}
  form.onsubmit= (event) => {
    event.preventDefault()

    let form= dialog.getElementsByTagName('form')[0]
    let formData= new FormData(form)
    scat.call("/sale/{{ txn.id }}/email-invoice", formData)
    .then((res) => res.json())
    .then((data) => {
      scat.alert('success', data.message)
      $(dialog).modal('hide')
    })
  }
{% endblock %}
{'fraction_non_alphanumeric': 0.20417570498915402, 'fraction_numerical': 0.0021691973969631237, 'mean_word_length': 2.8267634854771786, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '943079', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1208, 'n_words': 247}