[%# 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 %]

[% inline_javascript = BLOCK %]
  function setsevdesc(theSelect) {
    var theValue = theSelect.options[theSelect.selectedIndex].value;
    if (theValue == 'blocker') {
      document.getElementById('blockerdesc').style.display = 'block';
      document.getElementById('critdesc').style.display = 'none';
    } else if (theValue == 'critical') {
      document.getElementById('blockerdesc').style.display = 'none';
      document.getElementById('critdesc').style.display = 'block';
    } else {
      document.getElementById('blockerdesc').style.display = 'none';
      document.getElementById('critdesc').style.display = 'none';
    }
  }

  var compdesc = new Array();
  [% FOREACH comp IN product.components %]
  compdesc['[% comp.name FILTER js %]'] = '[% comp.description FILTER js %]';
  [% END %]
  var serviceNowText = 'Use <a href="https://mozilla.service-now.com/">Service Now</a> to:<br>' +
                       'Request an LDAP/E-mail/etc. account<br>' +
                       'Desktop/Laptop/Printer/Phone/Tablet/License problem/order/request';

  compdesc['MOC: Service Requests'] = 'End-User requests for infrastructure support.<br><br>' +
                                      serviceNowText;

  compdesc['Mailing List'] = 'Mailing list requests should be filed ' +
                             '<a href="[% basepath FILTER none %]enter_bug.cgi?product=mozilla.org&amp;format=mozlist">here</a> instead.';

  function setcompdesc(theRadio) {
    if (theRadio.id == 'component_service_desk') {
      document.getElementById('main_form').style.display = 'none';
      document.getElementById('service_now_form').style.display = '';
      document.getElementById('list_form').style.display = 'none';
      document.getElementById('compdescription').innerHTML = serviceNowText;
    } else if (theRadio.id == 'component_list') {
      document.getElementById('main_form').style.display = 'none';
      document.getElementById('service_now_form').style.display = 'none';
      document.getElementById('list_form').style.display = '';
      document.getElementById('compdescription').innerHTML = compdesc[theRadio.value];
    } else {
      document.getElementById('main_form').style.display = '';
      document.getElementById('service_now_form').style.display = 'none';
      document.getElementById('list_form').style.display = 'none';
      document.getElementById('compdescription').innerHTML = compdesc[theRadio.value];
    }
  }

  function on_submit() {
    if (document.getElementById('component_service_desk').checked) {
      document.location.href = 'https://mozilla.service-now.com/';
      return false;
    } else if (document.getElementById('component_list').checked) {
      document.location.href = '[% ulrbase FILTER none %]enter_bug.cgi?product=mozilla.org&format=mozlist';
      return false;
    } else {
      return true;
    }
  }

  YAHOO.util.Event.onDOMReady(function() {
    var comps = document.getElementsByName('component');
    for (var i = 0, l = comps.length; i < l; i++) {
      if (comps[i].checked) {
        setcompdesc(comps[i]);
        break;
      }
    }
  });
[% END %]

[% PROCESS global/header.html.tmpl
   title = "Mozilla Corporation/Foundation IT Requests"
   generate_api_token = 1
   javascript = inline_javascript
   javascript_urls = [ 'js/field.js' ]
%]

[% USE Bugzilla %]

<p><strong>Please use this form for IT requests only!</strong></p>
<p>If you have a [% terms.bug %] to file, go <a href="[% basepath FILTER none %]enter_bug.cgi">here</a>.</p>

<form method="post" action="[% basepath FILTER none %]post_bug.cgi" id="itRequestForm" enctype="multipart/form-data"
      onsubmit="return on_submit()">
  <input type="hidden" name="filed_via" value="custom_form">
  <input type="hidden" id="product" name="product" value="Infrastructure & Operations">
  <input type="hidden" name="rep_platform" value="All">
  <input type="hidden" name="op_sys" value="Other">
  <input type="hidden" name="bug_type" value="task">
  <input type="hidden" name="version" value="other">
  <input type="hidden" name="token" value="[% token FILTER html %]">
  <table>
    <tr>
      <td style="white-space: nowrap; vertical-align: top" align="right"><strong>Request Type:</strong></td>
      <td style="white-space: nowrap; vertical-align: top">
        <input type="radio" name="component" id="component_service_desk" onclick="setcompdesc(this)" value="Desktop Issues">
        <label for="component_service_desk">Service Desk issue/request</label><br>
        <input type="radio" name="component" id="component_relops" onclick="setcompdesc(this)" value="RelOps">
        <label for="component_relops">Report a problem with a build/testing machine</label><br>
        <input type="radio" name="component" id="component_webops_other" onclick="setcompdesc(this)" value="WebOps: Other">
        <label for="component_webops_other">Report a problem with a Mozilla website, or to request a change or push</label><br>
        <input type="radio" name="component" id="component_netops_acl" onclick="setcompdesc(this)" value="NetOps: DC Other">
        <label for="component_netops_acl">Request a firewall change</label><br>
        <input type="radio" name="component" id="component_list" onclick="setcompdesc(this)" value="Mailing List">
        <label for="component_list">Mailing list request</label><br>
        <input type="radio" name="component" id="component_moc" onclick="setcompdesc(this)" value="MOC: Service Requests">
        <label for="component_moc">Any other issue</label><br>
      </td>
      <td id="compdescription" align="left" style="color: green; padding-left: 1em; vertical-align: top">
      </td>
    </tr>

    <tbody id="main_form" style="display:none">

      <tr>
        <td align="right"><strong>Summary:</strong></td>
        <td colspan="3">
          <input name="short_desc" size="60" value="[% short_desc FILTER html %]">
        </td>
      </tr>

      <tr>
        <td align="right"><strong>CC&nbsp;(optional):</strong></td>
        <td colspan="3">
          [% INCLUDE global/userselect.html.tmpl
            id => "cc"
            name => "cc"
            value => cc
            size => 60
            multiple => 5
          %]
        </td>
      </tr>

      <tr><td align="right" valign="top"><strong>Description:</strong></td>
        <td colspan="3">
          <textarea name="comment" rows="10" cols="80">
            [% comment FILTER html %]</textarea>
          <br>
        </td>
      </tr>

      <tr>
        <td align="right"><strong>URL&nbsp;(optional):</strong></td>
        <td colspan="3">
          <input name="bug_file_loc" size="60"
                value="[% bug_file_loc FILTER html %]" placeholder="https://">
        </td>
      </tr>

      <tr><td colspan="4">&nbsp;</td></tr>

      <tr>
        <td colspan="4">
          <strong>Attachment&nbsp;(optional):</strong>
        </td>
      </tr>

      <tr>
        <td align="right">File:</td>
        <td colspan="3">
          <em>Enter the path to the file on your computer.</em><br>
          <input type="file" id="data" name="data" size="50">
          <input type="hidden" name="contenttypemethod" value="autodetect">
        </td>
      </tr>

      <tr>
        <td align="right">Description:</td>
        <td colspan="3">
          <em>Describe the attachment briefly.</em><br>
          <input type="text" id="description" name="description" size="60" maxlength="200">
        </td>
      </tr>

      <tr>
        <td>&nbsp;</td>
        <td>
          <br>
          <!-- infra -->
          <input type="checkbox" name="groups" id="groups" value="infra" checked="checked">
          <label for="groups"><strong>This is an internal issue which should not be publicly visible.</strong></label><br>
          (please uncheck this box if it isn't)<br>
          <br>
          <input type="submit" id="commit" value="Submit Request"><br>
          <br>
          Thanks for contacting us.  You will be notified by email of any progress made in resolving your request.
        </td>
      </tr>

    </tbody>

    <tbody id="service_now_form" style="display:none">
      <tr>
        <td>&nbsp;</td>
        <td>
          <br>
          <input type="submit" value="Go to Service Now">
        </td>
      </tr>
    </tbody>

    <tbody id="list_form" style="display:none">
      <tr>
        <td>&nbsp;</td>
        <td>
          <br>
          <input type="submit" value="Go to Mailing List form">
        </td>
      </tr>
    </tbody>

  </table>
</form>


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