[% PROCESS "elements.html" %]
<body>
  <form id="system-templates"
        data-dojo-type="lsmb/Form"
        action="template.pl"
        method="post"
        enctype="multipart/form-data">
    <div data-dojo-type="lsmb/TemplateManager"
         data-dojo-props="state:'[% state %]'"
         id="template-manager">
      <input type="hidden" name="template_name" id="shadow-template"
             data-dojo-attach-point="shadowTemplate">
      <input type="hidden" name="format" id="shadow-format"
             data-dojo-attach-point="shadowFormat">
      <input type="hidden" name="language" id="shadow-language"
             data-dojo-attach-point="shadowLanguage">
      <div id="template-variant">
        <div>
          <label for="template-name"
                 style="display:inline-block;width:15ex"
                 >[% text("Template") %]</label>
          <div data-dojo-type="dijit/form/Select"
               id="template-name"
               style="width:20ex"
               data-dojo-props="required:true,value:'[% template_name %]'"
               data-dojo-attach-point="templateName">
            <span value=""><span>[% text("--TEMPLATE--") %]</span></span>
            <span value="print_journal_entry">
              <span>[% text("GL transaction") %]</span></span>
            <span value="print_cash_transfer">
              <span>[% text("Cash Transfer transaction") %]</span></span>
            <span value="ap_transaction">
              <span>[% text("AP transaction") %]</span></span>
            <span value="ar_transaction">
              <span>[% text("AR transaction") %]</span></span>
            <span value="balance_sheet">
              <span>[% text("Balance sheet") %]</span></span>
            <span value="PNL">
              <span>[% text("Income statement") %]</span></span>
            <span value="bin_list">
              <span>[% text("Bin list") %]</span></span>
            <span value="check">
              <span>[% text("Single check") %]</span></span>
            <span value="check_base">
            <span>[% text("Check (base)") %]</span></span>
            <span value="check_multiple">
              <span>[% text("Multiple checks") %]</span></span>
            <span value="envelope">
              <span>[% text("Envelope") %]</span></span>
            <span value="invoice">
              <span>[% text("Invoice") %]</span></span>
            <span value="letterhead">
              <span>[% text("Letterhead") %]</span></span>
            <span value="packing_list">
              <span>[% text("Packing list") %]</span></span>
            <span value="pick_list">
              <span>[% text("Pick list") %]</span></span>
            <span value="printPayment">
              <span>[% text("Payment") %]</span></span>
            <span value="product_receipt">
              <span>[% text("Product receipt") %]</span></span>
            <span value="purchase_order">
            <span>[% text("Purchase order") %]</span></span>
            <span value="receipt">
              <span>[% text("Receipt") %]</span></span>
            <span value="request_quotation">
              <span>[% text("Request for quotation") %]</span></span>
            <span value="sales_order">
              <span>[% text("Sales order") %]</span></span>
            <span value="sales_quotation">
              <span>[% text("Sales quotation") %]</span></span>
            <span value="shipping_label">
              <span>[% text("Shipping label") %]</span></span>
            <span value="statement">
              <span>[% text("Aging statement") %]</span></span>
            <span value="timecard">
              <span>[% text("Timecard") %]</span></span>
            <span value="work_order">
              <span>[% text("Work order") %]</span></span>
            <span value="display_report">
              <span>[% text("Reports") %]</span></span>
            <span value="1099-MISC">
              <span>[% text("1099-MISC") %]</span></span>
            <span value="1099-INT">
              <span>[% text("1099-INT") %]</span></span>
          </div>
        </div>
        <div style="margin-top:8px">
          <label for="format"
                 style="display:inline-block;width:15ex"
                 >[% text("Format") %]</label>
          <div data-dojo-type="dijit/form/Select"
               id="format"
               style="width:20ex"
               data-dojo-props="required:true,value:'[% format %]'"
               data-dojo-attach-point="templateFormat">
            <span value=""><span>[% text("--FORMAT--") %]</span></span>
            <span value="csv"><span>[% text("csv") %]</span></span>
            <span value="html"><span>[% text("html") %]</span></span>
            <span value="tex"><span>[% text("tex") %]</span></span>
          </div>
          <label for="language"
                 style="margin-left:14ex;display:inline-block;width:15ex">Language</label>
          <div data-dojo-type="dijit/form/Select"
               id="language"
               style="width:18ex"
               data-dojo-props="value:'[% language %]'"
               data-dojo-attach-point="templateLanguage">
            <span value="__all__"><b>[% text("None/Generic") %]</b></span>
            [%
              FOREACH lang IN languages %]
            <span value="[% lang.code %]">[% lang.description %]</span>
            [%
              END
              %]
          </div>
        </div>
      </div>

      <div id="template-buttons">
        <button id="create"
                data-dojo-type="dijit/form/Button"
                data-dojo-attach-point="createButton"
                >[% text("Create") %]</button>

        <button id="edit"
                data-dojo-type="dijit/form/Button"
                data-dojo-attach-point="editButton"
                >[% text("Edit") %]</button>

        <button id="upload"
                data-dojo-type="dijit/form/Button"
                data-dojo-attach-point="uploadButton"
                >[% text("Upload") %]</button>
      </div>
      <div id="template-upload">
        <input type="file"
               name="template_content"
               id="template-content"
               >
        <button id="upload-save"
                name="__action"
                value="save"
                type="submit"
                data-dojo-type="dijit/form/Button"
                >[% text("Save") %]</button>
        <button id="upload-cancel"
                data-dojo-type="dijit/form/Button"
                data-dojo-attach-point="uploadCancelButton"
                >[% text("Cancel") %]</button>
      </div>
      <div id="template-edit">
        <div id="template-edit-buttons">
          <button id="edit-save"
                  name="__action"
                  value="save"
                  type="submit"
                  data-dojo-type="dijit/form/Button"
                  data-dojo-attach-point="editSaveButton"
                  >[% text("Save") %]</button>
          <button id="edit-cancel"
                  name="__action"
                  value="edit_cancel"
                  data-dojo-type="dijit/form/Button"
                  data-dojo-attach-point="editCancelButton"
                  >[% text("Cancel") %]</button>
        </div>

        [% PROCESS textarea element_data = {
                        class="template-body " _ format _ " editor"
                        style="width:100%;display:block"
                        name="template"
                        'data-dojo-attach-point'="templateContent"
                 text=UNESCAPE(template_content) } %]
      </div>
    </div>
  </form>
</body>
