[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[% PROCESS global/variables.none.tmpl %]

[% PROCESS global/header.html.tmpl
   title = "Mozilla Reps Swag Request Form"
   generate_api_token = 1
   javascript_urls = [ 'extensions/REMO/web/js/swag.js',
                       'extensions/REMO/web/js/form_validate.js',
                       'js/field.js' ]
   style_urls = [ "extensions/REMO/web/styles/moz_reps.css" ]
%]

[% IF !user.in_group("mozilla-reps") %]
  <p>Sorry, you do not have access to this page.</p>
  [% RETURN %]
[% END %]


<p>These requests will only be visible to the person who submitted the request,
any persons designated in the CC line, and authorized members of the Mozilla Rep team.</p>

<script [% script_nonce FILTER none %]>
function trySubmit() {
  var eventname = document.getElementById('eventname').value;
  var shortdesc = 'Swag Request - ' + eventname;
  document.getElementById('short_desc').value = shortdesc;
  return true;
}

function validateAndSubmit() {
  var alert_text = '';
  if(!isFilledOut('firstname')) alert_text += "Please enter your first name\n";
  if(!isFilledOut('lastname')) alert_text += "Please enter your last name\n";
  if(!isFilledOut('profilepage')) alert_text += "Please enter your Mozilla Reps profile page\n";
  if(!isFilledOut('eventname')) alert_text += "Please enter your event name\n";
  if(!isFilledOut('eventpage')) alert_text += "Please enter the event page.\n";
  if(!isFilledOut('attendance')) alert_text += "Please enter the estimated attendance.\n";
  if(!isFilledOut('shiptofirstname')) alert_text += "Please enter the shipping first name\n";
  if(!isFilledOut('shiptolastname')) alert_text += "Please enter the shipping last name\n";
  if(!isFilledOut('shiptoaddress1')) alert_text += "Please enter the ship to address\n";
  if(!isFilledOut('shiptocity')) alert_text += "Please enter the ship to city\n";
  if(!isFilledOut('shiptocountry')) alert_text += "Please enter the ship to country\n";
  if(!isFilledOut('shiptopcode')) alert_text += "Please enter the ship to postal code\n";
  if(!isFilledOut('shiptophone')) alert_text += "Please enter the ship to contact number\n";

  //Everything required is filled out..try to submit the form!
  if(alert_text == '') {
    return trySubmit();
  }

  //alert text, stay here on the page
  alert(alert_text);
  return false;
}

</script>

<h1>Mozilla Reps - Swag Request Form</h1>

<p>Review the <a href="https://wiki.mozilla.org/ReMo/SOPs/Swag_Requests" target="_blank" rel="noopener noreferrer">
  Swag Requests SOP</a> before you complete this form.</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="swagRequestForm" enctype="multipart/form-data"
      onSubmit="return validateAndSubmit();">

  <input type="hidden" name="filed_via" value="custom_form">
  <input type="hidden" name="format" value="remo-swag">
  <input type="hidden" name="bug_type" value="task">
  <input type="hidden" name="product" value="Mozilla Reps">
  <input type="hidden" name="component" value="Swag Requests">
  <input type="hidden" name="rep_platform" value="All">
  <input type="hidden" name="op_sys" value="Other">
  <input type="hidden" name="version" value="unspecified">
  <input type="hidden" name="short_desc" id="short_desc" value="">
  <input type="hidden" name="groups" value="mozilla-reps">
  <input type="hidden" name="token" value="[% token FILTER html %]">

<table id="reps-form">

<tr class="odd">
  <td><strong>First Name: <span style="color: red;" title="Required">*</span></strong></td>
  <td>
    <input type="text" name="firstname" id="firstname" placeholder="John" size="40">
  </td>
</tr>

<tr class="even">
  <td><strong>Last Name: <span style="color: red;" title="Required">*</span></strong></td>
  <td>
    <input type="text" name="lastname" id="lastname" placeholder="Doe" size="40">
  </td>
</tr>

<tr class="odd">
  <td>
    <strong>Mozilla Reps Profile Page:
      <span style="color: red;" title="Required">*</span></strong>
  </td>
  <td>
    <input type="text" name="profilepage" id="profilepage" size="40">
  </td>
</tr>

<tr class="even">
  <td><strong>Event Name: <span style="color: red;" title="Required">*</span></strong></td>
  <td>
    <input type="text" name="eventname" id="eventname" size="40">
  </td>
</tr>

<tr class="odd">
  <td><strong>Event Page: <span style="color: red;" title="Required">*</span></strong></td>
  <td>
    <input type="text" name="eventpage" id="eventpage" size="40">
  </td>
</tr>

<tr class="even">
  <td><strong>Estimated Attendance: <span style="color: red;" title="Required">*</span></strong></td>
  <td>
    <select id="attendance" name="attendance">
      <option value="1-50">1-50</option>
      <option value="51-200">51-200</option>
      <option value="201-500">201-500</option>
      <option value="501-1000+">501-1000+</option>
    </select>
  </td>
</tr>


<tr class="odd">
  <td><!--spacer-->&nbsp;</td>
  <td><!--spacer-->&nbsp;</td>
</tr>

<tr class="even">
  <td colspan="2"><strong>Shipping Details:</strong></td>
</tr>

<tr class="odd">
  <td><strong>Ship Before:</strong>
  <td>
    [% INCLUDE bug/field.html.tmpl
       bug      = default,
       field    = bug_fields.cf_due_date
       value    = default.cf_due_date,
       editable = 1,
       no_tds   = 1
    %]
  </td>
</tr>

<tr class="even">
  <td><strong>First Name: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptofirstname" id="shiptofirstname" placeholder="John" size="40"></td>
</tr>

<tr class="odd">
  <td><strong>Last Name: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptolastname" id="shiptolastname" placeholder="Doe" size="40"></td>
</tr>

<tr class="even">
  <td><strong>Address Line 1: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptoaddress1" id="shiptoaddress1" placeholder="123 Main St." size="40"></td>
</tr>

<tr class="odd">
  <td><strong>Address Line 2:</strong></td>
  <td><input name="shiptoaddress2" id="shiptoaddress2" size="40"></td>
</tr>

<tr class="even">
  <td><strong>City: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptocity" id="shiptocity" size="40" placeholder="Anytown"></td>
</tr>

<tr class="odd">
  <td><strong>State/Region (if applicable):</strong></td>
  <td><input name="shiptostate" id="shiptostate" placeholder="CA" size="40"></td>
</tr>

<tr class="even">
  <td><strong>Country: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptocountry" id="shiptocountry" placeholder="USA" size="40"></td>
</tr>

<tr class="odd">
  <td><strong>Postal Code: <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptopcode" id="shiptopcode" placeholder="90210" size="40"></td>
</tr>

<tr class="even">
  <td><strong>Phone (including country code): <span style="color: red;" title="Required">*</span></strong></td>
  <td><input name="shiptophone" id="shiptophone" placeholder="919-555-1212" size="40"></td>
</tr>

<tr class="odd">
  <td><strong>Custom Reference<br>
    (Fiscal or VAT-number, if known):</strong><br><small>(if your country requires this)</small>
  </td>
  <td><input name="shiptoidrut" id="shiptoidrut" size="40"></td>
</tr>

<tr class="even">
  <td colspan="2">
    <strong>Addition information for delivery person:</strong><br>
    <textarea id="shipadditional" name="shipadditional" rows="4"></textarea>
  </td>
</tr>

<tr class="odd">
  <td><!--spacer-->&nbsp;</td>
  <td><!--spacer-->&nbsp;</td>
</tr>

<tr class="even">
  <td colspan="2"><strong>Swag Requested:</strong></td>
</tr>

<tr class="odd">
  <td><strong>Stickers:</strong></td>
  <td><input type="checkbox" id="stickers" name="stickers" value="1"></td>
</tr>

<tr class="even">
  <td><strong>Buttons:</strong></td>
  <td><input type="checkbox" id="buttons" name="buttons" value="1"></td>
</tr>

<tr class="odd">
  <td><strong>Lanyards:</strong></td>
  <td><input type="checkbox" id="lanyards" name="lanyards" value="1"></td>
</tr>

<tr class="even">
  <td><strong>T-Shirts:</strong></td>
  <td><input type="checkbox" id="tshirts" name="tshirts" value="1"></td>
</tr>

<tr class="odd">
  <td><strong>Silicone Wristband:</strong></td>
  <td><input type="checkbox" id="wristband" name="wristband" value="1"></td>
</tr>

<tr class="even">
  <td><strong>Firefox Tattoos:</strong></td>
  <td><input type="checkbox" id="tattoos" name="tattoos" value="1"></td>
</tr>

<tr class="odd">
  <td><strong>Other:</strong> (please specify)</td>
  <td><input type="text" id="otherswag" name="otherswag" size="40"></td>
</tr>

<tr class="even">
  <td>&nbsp;</td>
  <td align="right">
    <input type="submit" id="commit" value="Submit Request">
  </td>
</tr>

</table>

<p>
  Quantities of different swag items requested that will actually be shipped
  depend on stock availability and number of attendees. Mozilla cannot guarantee
  that all items requested will be in stock at the time of shipment and you will
  be notified in case an item cannot be shipped. Please request swag at least 1
  month before desired delivery date.
</p>

<p>
  <strong><span style="color: red;">*</span></strong> - Required field<br>
  Thanks for contacting us.
   You will be notified by email of any progress made in resolving your request.
</p>

[% PROCESS global/footer.html.tmpl %]
