# --
# AgentTicketEmail.dtl - provides HTML form for agent email
# Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
# --
# $Id: AgentTicketEmail.dtl,v 1.36 2008/07/01 15:51:02 martin Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl-2.0.txt.
# --

# include AJAX lib
$Include{"AJAX"}

<!-- start form -->
<script language="JavaScript" type="text/javascript">
<!--
function submit_compose() {
    if (document.compose.TypeID && document.compose.TypeID.value == "") {
        alert('$JSText{"Ticket Type is required!"}');
        document.compose.TypeID.focus();
        return false;
    }
    else if (document.compose.Subject.value == "") {
        alert('$JSText{"A message should have a subject!"}');
        document.compose.Subject.focus();
        return false;
    }
    else if (document.compose.Body.value == "") {
        alert('$JSText{"A message should have a body!"}');
        document.compose.Body.focus();
        return false;
    }
    else if (isNaN(document.compose.Day.value) || isNaN(document.compose.Month.value) || isNaN(document.compose.Year.value) || isNaN(document.compose.Hour.value) || isNaN(document.compose.Minute.value)) {
        alert('$JSText{"Invalid date!"}');
        return false;
    }
    else if (document.compose.Day.value < 1 || document.compose.Day.value > 31 || document.compose.Month.value < 1 || document.compose.Month.value > 31 || document.compose.Year.value < 999 || document.compose.Year.value > 10000 || document.compose.Hour.value < 0 || document.compose.Hour.value > 23 ||document.compose.Minute.value < 0 || document.compose.Minute.value > 59  ) {
        alert('$JSText{"Invalid date!"}');
        return false;
    }
<!-- dtl:block:TicketFreeTextCheckJs -->
    else if (document.compose.$Data{"TicketFreeTextField"}.value == "") {
        alert('$JSText{"A required field is:"} ' + document.compose.$Data{"TicketFreeKeyField"}.value + '!');
        document.compose.$Data{"TicketFreeTextField"}.focus();
        return false;
    }
<!-- dtl:block:TicketFreeTextCheckJs -->
<!-- dtl:block:TicketFreeTimeCheckJs -->
    if (document.compose.$Data{"TicketFreeTimeCheck"} && document.compose.$Data{"TicketFreeTimeCheck"}.checked == false) {
        alert('$JSText{"A required field is:"} $QData{"TicketFreeTimeKey"}!');
        document.compose.$Data{"TicketFreeTimeCheck"}.focus();
        return false;
    }
<!-- dtl:block:TicketFreeTimeCheckJs -->
<!-- dtl:block:TimeUnitsJs -->
    else if (document.compose.TimeUnits.value != "") {
        var reg = /^-{0,1}\d+?((\.|,){0,1}\d+?){0,1}$/;
        if (reg.test(document.compose.TimeUnits.value) == false) {
            alert('$JSText{"Invalid time!"}');
            document.compose.TimeUnits.focus();
            return false;
        }
    }
    else if (document.compose.TimeUnits.value == "" && $Config{"Ticket::Frontend::NeedAccountedTime"}) {
        alert('$JSText{"You need to account time!"}');
        document.compose.TimeUnits.focus();
        return false;
    }
<!-- dtl:block:TimeUnitsJs -->
    else {
        return true;
    }
}
//-->
</script>

<script language="JavaScript" type="text/javascript">
<!--
function SpellCheckSubmit() {
    document.spelling.Body.value = document.compose.Body.value;
    window.open('', 'spelling', 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=100,top=100');
    document.spelling.submit()
}
// -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
function BookCheckSubmit() {
    document.book.To.value = document.compose.To.value;
    document.book.Cc.value = document.compose.Cc.value;
    document.book.Bcc.value = document.compose.Bcc.value;
    window.open('', 'book', 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=100,top=100');
    document.book.submit()
    document.book.was_spell_checked=true;
}
// -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
function FAQSubmit() {
    window.open('', 'faq', 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=100,top=100');
    document.faq.submit()
}
// -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
function CustomerSubmit() {
    window.open('', 'customer', 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=700,height=550,left=100,top=100');
    document.customer.submit()
}
// -->
</script>

<script language="JavaScript" type="text/javascript">
<!--
function clear_field() {
    document.compose.To.value = "";
    document.compose.To.focus();
}
//-->
</script>

<table border="0" width="100%" cellspacing="0" cellpadding="3">
  <tr>
    <td align="left" class="mainhead">
      $Env{"Box0"}$Text{"Compose Email"} / $Text{"new ticket"}$Env{"Box1"}
    </td>
  </tr>
  <tr>
    <td class="mainbody">
      <p>
        <form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" name="compose">
          <input type="hidden" name="Action" value="$Env{"Action"}"/>
          <input type="hidden" name="Subaction" value="StoreNew"/>
          <input type="hidden" name="FormID" value="$QData{"FormID"}"/>
          <input type="hidden" name="ExpandCustomerName" value="0"/>
          <input type="hidden" name="OwnerAll" value="$QData{"OwnerAll"}"/>
          <input type="hidden" name="ResponsibleAll" value="$QData{"ResponsibleAll"}"/>
          <input type="hidden" name="PreSelectedCustomerUser" value=""/>
          <input type="hidden" name="SelectedCustomerUser" value="$Data{"CustomerUser"}"/>
          <input type="hidden" name="TicketID" value="$Data{"TicketID"}"/>
          <table border="0" width="100%">
<!-- dtl:block:TicketType -->
            <tr>
              <td class="contentkey">$Text{"Type"}:</td>
              <td class="contentvalue"> $Data{"TypeStrg"}</td>
            </tr>
<!-- dtl:block:TicketType -->
            <tr>
              <td width="20%" class="contentkey">$Text{"From"}:</td>
              <td width="60%" class="contentvalue">$Data{"FromStrg"} <font color="red" size="-2">$Text{"$Data{"Destination invalid"}"}</font>
<!-- dtl:block:FromUpdateSubmit -->
                <input class="button" type="submit" value="$Text{"Refresh"}" name="ExpandCustomerName2"/>
<!-- dtl:block:FromUpdateSubmit -->
              </td>
              <td width="20%" rowspan="10" class="contentvalue">
# show customer info table
<!-- dtl:block:CustomerTable -->
                <p>
                  <b>$Text{"Customer Info"}</b>:<br/>
                  $Data{"CustomerTable"}
                </p>
<!-- dtl:block:CustomerTable -->
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"To"}:</td>
              <td class="contentvalue">
                <input type="text" name="To" value="$QData{"To"}" size="70"/>
                <font color="red" size="-2">$Text{"$Data{"To invalid"}"}</font>
                <br/>
                $Data{"CustomerUserStrg"}
                <dtl if ($Data{"CustomerUserStrg"} ne "") { $Data{"TakeThisCustomer"} = "<br/><input class="button" type="submit" name="ExpandCustomerName2" value="$Text{"Take this Customer"}"/>"; }>
                $Data{"TakeThisCustomer"}
                <input class="button" type="submit" name="ExpandCustomerName1" value="$Text{"Search Customer"}"/>
                <input class="button" type="submit" name="ClearTo" value="$Text{"Clear To"}" onclick="javascript:clear_field(); return false;"/>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Cc"}:</td>
              <td class="contentvalue">
                <input type="text" name="Cc" value="$QData{"Cc"}" size="70"/>
                <font color="red" size="-2">$Text{"$Data{"Cc invalid"}"}</font>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Bcc"}:</td>
              <td class="contentvalue">
                <input type="text" name="Bcc" value="$QData{"Bcc"}" size="70"/>
                <font color="red" size="-2">$Text{"$Data{"Bcc invalid"}"}</font>
              </td>
            </tr>
<!-- dtl:block:TicketService -->
            <tr>
              <td class="contentkey">$Text{"Service"}:</td>
              <td class="contentvalue">
                $Data{"ServiceStrg"}
                <font color="red" size="-2">$Text{"$Data{"Service invalid"}"}</font>
              </td>
            </tr>
<!-- dtl:block:TicketService -->
<!-- dtl:block:TicketSLA -->
            <tr>
              <td class="contentkey">$Text{"SLA"}:</td>
              <td class="contentvalue">
                $Data{"SLAStrg"}
                <font color="red" size="-2">$Text{"$Data{"SLA invalid"}"}</font>
              </td>
            </tr>
<!-- dtl:block:TicketSLA -->
<!-- dtl:block:OwnerSelection -->
            <tr>
              <td class="contentkey">$Text{"Owner"}:</td>
              <td class="contentvalue">$Data{"OptionStrg"}
<!-- dtl:block:OwnerSelectionAllJS -->
#              $Env{"Box0"}<a href="" onclick="document.compose.ExpandCustomerName.value='3'; document.compose.OwnerAll.value='1'; document.compose.submit(); return false;" onmouseout="window.status='';" onmouseover="window.status='$JSText{"All Agents"}'; return true;">$Text{"All"}</a>$Env{"Box1"}
                $Env{"Box0"}<a href="" onclick="document.compose.OwnerAll.value='1'; AJAXUpdate('AJAXUpdate', 'OwnerAll', ['OwnerAll', 'Dest'], ['NewUserID']); return false;" onmouseout="window.status='';" onmouseover="window.status='$JSText{"All Agents"}'; return true;">$Text{"All"}</a>$Env{"Box1"}
<!-- dtl:block:OwnerSelectionAllJS -->
<!-- dtl:block:OwnerSelectionAllSubmit -->
                <input class="button" type="submit" value="$Text{"All"}" name="OwnerAllRefresh"/>
<!-- dtl:block:OwnerSelectionAllSubmit -->
              </td>
            </tr>
<!-- dtl:block:OwnerSelection -->
<!-- dtl:block:ResponsibleSelection -->
            <tr>
              <td class="contentkey">$Text{"Responsible"}:</td>
              <td class="contentvalue">$Data{"ResponsibleOptionStrg"}
<!-- dtl:block:ResponsibleSelectionAllJS -->
#              $Env{"Box0"}<a href="" onclick="document.compose.ExpandCustomerName.value='3'; document.compose.ResponsibleAll.value='1'; document.compose.submit(); return false;" onmouseout="window.status='';" onmouseover="window.status='$JSText{"All Agents"}'; return true;">$Text{"All"}</a>$Env{"Box1"}
                $Env{"Box0"}<a href="" onclick="document.compose.ResponsibleAll.value='1'; AJAXUpdate('AJAXUpdate', 'ResponsibleAll', ['ResponsibleAll', 'Dest'], ['NewResponsibleID']); return false;" onmouseout="window.status='';" onmouseover="window.status='$JSText{"All Agents"}'; return true;">$Text{"All"}</a>$Env{"Box1"}
<!-- dtl:block:ResponsibleSelectionAllJS -->
<!-- dtl:block:ResponsibleSelectionAllSubmit -->
                <input class="button" type="submit" value="$Text{"All"}" name="ResponsibleAllRefresh"/>
<!-- dtl:block:ResponsibleSelectionAllSubmit -->
              </td>
            </tr>
<!-- dtl:block:ResponsibleSelection -->
<!-- dtl:block:Option -->
            <tr>
              <td class="contentkey">$Text{"$QData{"Key"}"}:</td>
              <td class="contentvalue">$Data{"Value"} <font color="red" size="-2">$Data{"Invalid"}</font></td>
            </tr>
<!-- dtl:block:Option -->
            <tr>
              <td class="contentkey">$Text{"Subject"}:</td>
              <td class="contentvalue">
                <input type="text" name="Subject" value="$QData{"Subject"}" size="70"/>
                <font color="red" size="-2">$Text{"$Data{"Subject invalid"}"}</font>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Options"}:</td>
              <td class="contentvalue">
<!-- dtl:block:SpellCheck -->
                $Env{"Box0"}<a href="" onclick="SpellCheckSubmit(); return false;" onmouseover="window.status='$JSText{"Spell Check"}'; return true;" onmouseout="window.status='';"><img border="0" src="$Env{"Images"}spell.png">$Text{"Spell Check"}</a>$Env{"Box1"}
<!-- dtl:block:SpellCheck -->
<!-- dtl:block:AddressBook -->
                $Env{"Box0"}<a href="" onclick="BookCheckSubmit(); return false;" onmouseover="window.status='$JSText{"Address Book"}'; return true;" onmouseout="window.status='';"><img border="0" src="$Env{"Images"}contents.png">$Text{"Address Book"}</a>$Env{"Box1"}
<!-- dtl:block:AddressBook -->
                $Env{"Box0"}<a href="#attachment" onmouseover="window.status='$JSText{"Attachments"}'; return true;" onmouseout="window.status='';"><img border="0" src="$Env{"Images"}attach.png">$Text{"Attachments"}</a>$Env{"Box1"}
# --
# check if the faq link should be shown
# --
                <dtl if ($Env{"UserIsGroupRo[faq]"} eq "Yes") { $Data{"FAQLink"} = "$Env{"Box0"}<a href="" onclick="FAQSubmit(); return false;" onmouseover="window.status='$JSText{"FAQ"}'; return true;" onmouseout="window.status='';"><img border="0" src="$Env{"Images"}help-small.png">$Text{"FAQ"}</a>$Env{"Box1"}"; }>
                $Data{"FAQLink"}
                $Env{"Box0"}<a href="" onclick="CustomerSubmit(); return false;" onmouseover="window.status='$JSText{"Customer"}'; return true;" onmouseout="window.status='';"><img border="0" src="$Env{"Images"}group-small.png">$Text{"Customer"}</a>$Env{"Box1"}
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Text"}:</td>
              <td class="contentvalue">
                <textarea name="Body" rows="15" cols="$Config{"Ticket::Frontend::TextAreaEmail"}" wrap="$Env{"BrowserWrap"}">$Data{"Body"}</textarea>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Signature"}:</td>
              <td class="contentvalue">
                <textarea name="Signature" rows="5" cols="82" wrap="$Env{"BrowserWrap"}" readonly>$Data{"Signature"}</textarea>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Attachment"}:</td>
              <td class="contentvalue">
                <table cellspacing="0" cellpadding="0" width="400">
<!-- dtl:block:Attachment -->
                  <tr>
                    <td>$QData{"Filename"}</td>
                    <td>$QData{"Filesize"}</td>
                    <td align="right">
                      <input class="button" type="submit" name="AttachmentDelete$QData{"FileID"}" value="$Text{"Delete"}"/>
                    </td>
                  </tr>
<!-- dtl:block:Attachment -->
                  <tr>
                    <td colspan="2"><input name="file_upload" type="file" size="40" class="fixed"/></td>
                    <td align="right">
                      <input class="button" type="submit" name="AttachmentUpload" value="$Text{"Attach"}"/>
                      <a name="attachment"></a>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"CustomerID"}:</td>
              <td class="contentvalue">
                <input type="text" name="CustomerID" value="$Data{"CustomerID"}" size="25"/>
              </td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Next ticket state"}:</td>
              <td class="contentvalue"> $Data{"NextStatesStrg"}</td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Pending Date"} ($Text{"for pending* states"}):</td>
              <td class="contentvalue">$Data{"PendingDateString"}<font color="red" size="-2">$Text{"$Data{"Date invalid"}"}</font></td>
            </tr>
            <tr>
              <td class="contentkey">$Text{"Priority"}:</td>
              <td class="contentvalue"> $Data{"PriorityStrg"}</td>
            </tr>
<!-- dtl:block:TicketFreeText -->
            <tr>
              <td class="contentkey">$Data{"TicketFreeKeyField"}:</td>
              <td class="contentvalue">$Data{"TicketFreeTextField"}</td>
            </tr>
<!-- dtl:block:TicketFreeText -->
#<!-- dtl:block:TicketFreeText1 -->
#            <tr>
#              <td class="contentkey">$Data{"TicketFreeKeyField1"}:</td>
#              <td class="contentvalue">$Data{"TicketFreeTextField1"}</td>
#            </tr>
#<!-- dtl:block:TicketFreeText1 -->
#<!-- dtl:block:TicketFreeText2 -->
#            <tr>
#              <td class="contentkey">$Data{"TicketFreeKeyField2"}:</td>
#              <td class="contentvalue">$Data{"TicketFreeTextField2"}</td>
#            </tr>
#<!-- dtl:block:TicketFreeText2 -->
<!-- dtl:block:TicketFreeTime -->
            <tr>
              <td class="contentkey">$Text{"$QData{"TicketFreeTimeKey"}"}:</td>
              <td class="contentvalue">$Data{"TicketFreeTime"}</td>
            </tr>
<!-- dtl:block:TicketFreeTime -->
#<!-- dtl:block:TicketFreeTime1 -->
#            <tr>
#              <td class="contentkey">$Text{"$Config{"TicketFreeTimeKey1"}"}:</td>
#              <td class="contentvalue">$Data{"TicketFreeTime1"}</td>
#            </tr>
#<!-- dtl:block:TicketFreeTime1 -->
#<!-- dtl:block:TicketFreeTime2 -->
#            <tr>
#              <td class="contentkey">$Text{"$Config{"TicketFreeTimeKey2"}"}:</td>
#              <td class="contentvalue">$Data{"TicketFreeTime2"}</td>
#            </tr>
#<!-- dtl:block:TicketFreeTime2 -->
<!-- dtl:block:ArticleFreeText -->
            <tr>
              <td class="contentkey">$Data{"ArticleFreeKeyField"}:</td>
              <td class="contentvalue">$Data{"ArticleFreeTextField"}</td>
            </tr>
<!-- dtl:block:ArticleFreeText -->
#<!-- dtl:block:ArticleFreeText1 -->
#                <tr>
#                  <td class="contentkey">$Data{"ArticleFreeKeyField1"}:</td>
#                  <td class="contentvalue">$Data{"ArticleFreeTextField1"}</td>
#                </tr>
#<!-- dtl:block:ArticleFreeText1 -->
#<!-- dtl:block:ArticleFreeText2 -->
#                <tr>
#                  <td class="contentkey">$Data{"ArticleFreeKeyField2"}:</td>
#                  <td class="contentvalue">$Data{"ArticleFreeTextField2"}</td>
#                </tr>
#<!-- dtl:block:ArticleFreeText2 -->
<!-- dtl:block:TimeUnits -->
            <tr>
              <td class="contentkey">$Text{"Time units"}$Text{"$Config{"Ticket::Frontend::TimeUnits"}"}:</td>
              <td class="contentvalue"> <input type="text" name="TimeUnits" value="$QData{"TimeUnits"}" size="3"/></td>
            </tr>
<!-- dtl:block:TimeUnits -->
          </table>
          <br/>
          <input class="button" accesskey="g" type="submit" value="$Text{"Send mail!"}" onclick="return submit_compose();"/>
        </form>
        <form action="$Env{"CGIHandle"}" method="post" name="spelling" target="spelling">
          <input type="hidden" name="Action" value="AgentSpelling"/>
          <input type="hidden" name="Body" value=""/>
          <input type="hidden" name="spell_lang" value=""/>
        </form>
        <form action="$Env{"CGIHandle"}" method="post" name="book" target="book">
          <input type="hidden" name="Action" value="AgentBook"/>
          <input type="hidden" name="To" value=""/>
          <input type="hidden" name="Cc" value=""/>
          <input type="hidden" name="Bcc" value=""/>
        </form>
        <form action="$Env{"CGIHandle"}" method="post" name="faq" target="faq">
          <input type="hidden" name="Action" value="AgentFAQ"/>
          <input type="hidden" name="Nav" value="None"/>
          <input type="hidden" name="Body" value=""/>
          <input type="hidden" name="Subject" value=""/>
          <input type="hidden" name="What" value=""/>
        </form>
        <form action="$Env{"CGIHandle"}" method="post" name="customer" target="customer">
          <input type="hidden" name="Action" value="AdminCustomerUser"/>
          <input type="hidden" name="Nav" value="None"/>
          <input type="hidden" name="Subject" value=""/>
          <input type="hidden" name="What" value=""/>
        </form>
      </p>
    </td>
  </tr>
</table>
<!-- end form -->
