<?/*
Copyright (C) 2003 Media Net Link, Inc. Danville, CA 94526 USA

This file is part of AthenaRMS.

AthenaRMS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

AthenaRMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/?>
<?php
 ## $comment_id_list - array of hashes which each hash containing comment info for the ticket
 ## $ticket - object filled with current ticket info
 ## $ticket_id
 ## $problem - name of the problem for the ticket (from $ticket->Get ('problem_id'))
 ## $config - config object to get CRM parameters and such

  require_once 'attribute_display.php';
  $ad = new Attribute_Display (); # get attribute names
  $attv = new Attribute_Value (); # get attribute values

  $person = $person_p->Info_by_Person_ID ($ticket->Get('user_person_id'));

  function date_fmt ($datestamp) {
    return date( 'M d Y g:ia', strtotime($datestamp) );
  }
?>

<?php
  require_once 'crm.php';
  $crm = new Crm ();
  $crm_id = $crm->CRM_ID_By_Host_Path ();
  $crm_rec = $crm->Select_by_CRM_ID ($crm_id);
  $crm_name = $crm_rec->Get('crm_name');
?>


<script type="text/javascript">
<!--
  function openit(sURL){
newwindow=open(sURL,"rlrpopupnav","width=370,height=240,directories=no,location=no,menubar=no,scrollbars=auto,status=no,toolbar=no,resizable=no,left=10%,top=10%,screenX=10%,screenY=10%");
}
//-->
</script>
<br />
<center>
<table border="0" cellpadding="0" cellspacing="0">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<tr>
  <td><img alt="" src="../../img/console-top-corn-left.gif" width="15" height="30" /></td>
  <td valign="top" align="center" background="../../img/console-vert-line-top.gif">
<table width='100%' border="0" height="23" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td class="textsm" align="left" valign="middle"><img alt="" src="../../img/cldot.gif" width="10" height="1" /><b class="supnavrmsttyl"><?php echo $crm_name; ?> request</b></td>
<td class="navlnk" align="right" valign="middle">

<table border="0" height="23" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td class="navlnk" align="center" valign="middle"><img src="../../img/console-spacer.gif" width="2" height="23" border="0" hspace="7" alt="" /></td>
<td class="navlnk" nowrap="nowrap" align="center" valign="middle"><a href="javascript:openit('../status_update/<?php echo $enc_id;?>')" class="navlnkstrong">Add Comments</a></td>
<td class="navlnk" align="center" valign="middle"><img src="../../img/console-spacer.gif" width="2" height="23" border="0" hspace="7" alt="" /></td>
</tr></table>

</td>
</tr></table>
</td>
  <td><img alt="" src="../../img/console-top-corn-right.gif" width="14" height="30" /></td>
</tr>
<tr>
  <td background="../../img/console-vert-line-left.gif"><img alt="" src="../../img/cldot.gif" width="4" height="1" /></td>
  <td width="550" align="left">

<!-- Start Outer Table -->


<table width="100%" border="0" cellpadding="5" cellspacing="0">
    <tr>
      <td>

<table border="0" cellspacing="0" cellpadding="0" width="100%">
            <tr>
              <td nowrap="nowrap" align="left" valign="top">


<table border="0" cellpadding="0" cellspacing="0"><tr><td>
<!--Start Ticket-->
                <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td rowspan="3"><img alt="" src="../../img/ticket-lf.gif" width="8" height="70" /></td>
                  <td valign="top" colspan="2" height="3" background="../../img/ticket-top.gif"><img alt="" src="../../img/cldot.gif" width="1" height="3" /></td>
                  <td rowspan="3"><img alt="" src="../../img/ticket-rt.gif" width="8" height="70" /></td>
                </tr>
                <tr>
                  <td valign="middle" align="center" bgcolor="C6E192" height="64" nowrap="nowrap" class="ticket">&nbsp;TICKET&nbsp;</td>
                  <td valign="middle" align="center" bgcolor="EDEDEE" height="64" nowrap="nowrap" class="ticketnumber">&nbsp; <?php echo $ticket_id; ?> &nbsp;</td>
                </tr>
                <tr>
                  <td valign="bottom" colspan="2" height="3" background="../../img/ticket-btm.gif"><img alt="" src="../../img/cldot.gif" width="1" height="3" /></td>
                </tr>
                </table>
<!--End Ticket-->
</td></tr>
<tr><td align="center" background="../../img/gradient.gif">

<!-- Start Status Table -->

                <table border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left" class="textsm"><b>Status:</b> <font color="red"> <?php echo $ticket->Get ('status'); ?></font></td>
                </tr>
                <tr>
                  <td align="left" class="textsm"><b>Opened:</b> <?php echo date_fmt( $ticket->Get('created_date') ); ?></td>
                </tr>
                <tr>
                  <td align="left" class="textsm"><b>Last Update:</b> <?php echo date_fmt( $ticket->Get('updated_date') ); ?></td>
                </tr>
               <!--
                <tr>
                  <td align="left" class="textsm">ticket owner name <?php print $person->Get ('first_name'); ?></td>
                </tr>
                -->
                </table>

<!-- End Status Table -->
</td>
</tr>
</table>

<!--Old Nav Table Went Here-->

</td>
<td align="right" valign="bottom">


<!--Old Status Table Went Here-->

<!--start nav-->

<table border="0" cellpadding="0" cellspacing="0" bgcolor="#e6f0ce">
<tr>
<td> <img src="../../img/elipsefill-top-corn-left.gif" width="16" height="15"></td>
<td background="../../img/elipsefill-vert-line-top.gif"><img src="../../img/cldot.gif" width="1" height="15"></td>
<td> <img src="../../img/elipsefill-top-corn-right.gif" width="15" height="15"></td>
</tr>
<tr>
<td background="../../img/elipsefill-vert-line-left.gif"><img src="../../img/cldot.gif" width="16" height="1"></td>
<td bgcolor="#e6f0ce" class="textsm" align="left">
<table border="0" cellspacing="0" cellpadding="2">
<tbody>
<tr>
<td nowrap="nowrap" align="left" class="textsm"><b><?php print $person->Get ('first_name'); ?> <?php print $person->Get ('last_name'); ?></b></td>
</tr>
<tr>
<td align="left" class="textsm" nowrap="nowrap" bgcolor="#f7faef"><b>company:</b> <?php print $person->Get ('company'); ?></td>
</tr>
<tr>
<td align="left" class="textsm"><b>subject:</b> <?php print $ticket->Get ('subject'); ?></td>
</tr>
<tr>
<td align="left" class="textsm" nowrap="nowrap" bgcolor="#f7faef"><b>phone:</b> <?php print $person->Get ('work_phone'); ?></td>
</tr>
<tr>
<td align="left" class="textsm" nowrap="nowrap"><b>email:</b> <?php print $person->Get ('email'); ?></td>
</tr>

</tbody></table></td>
<td background="../../img/elipsefill-vert-line-right.gif"><img src="../../img/cldot.gif" width="15" height="1"></td>
</tr>
<tr>
<td> <img src="../../img/elipsefill-btm-corn-left.gif" width="16" height="15"></td>
<td background="../../img/elipsefill-vert-line-btm.gif"><img src="../../img/cldot.gif" width="1" height="15"></td>
<td> <img src="../../img/elipsefill-btm-corn-right.gif" width="15" height="15"></td>
</tr>
</table>

<!--end nav-->

 </td>
</tr>
</table>

<!-- End Outer Table -->

          </td>
        </tr>
        <tr>
          <td align="center">
<!-- Start Comments Table -->

<table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>

<td align="center" valign="top">





                <table border="0" width="100%" cellspacing="0" cellpadding="3">
                <tbody>
<?php
  foreach ($comment_id_list as $r) {
    $attachments = $comment->Attachments ($r['comment_id']);

    $who = $config->Get ('Email Sig');

    if ($r['person_id'] == $user_pid) $who = 'you';

print <<<EOF
                <tr>
                  <td bgcolor="#E6F0CE" class="textsm" align="left"><b>At $r[created_date] $who wrote:</b></td>
                </tr>
                <tr>
                  <td align="left" class="textsm">
<table cellpadding="0" border="0" cellspacing="2" width="100%">
EOF;

    require_once 'icon_map.php';

    foreach ($attachments as $a) {
      $aname = htmlentities ($a['attachment_name']);
      $aname_link = rawurlencode ($a['attachment_name']);

      $atype = $a['attachment_type'];

      if ($atype) {
        $aimg = $ICONS[$atype];

        if (!$aimg) $aimg = $ICONS['default'];

        $desc = getimagesize ("../img/icons/$aimg");

        $img = "<img src=\"../../img/icons/$aimg\" $desc[3] align=\"ABSMIDDLE\" hspace=\"1\" vspace=\"1\" border=\"0\" alt=\"$aimg\" />";
      }

      print <<<EOF
            <tr>
              <td align="left" class="textsm"><a href="$_SERVER[SCRIPT_NAME]/../viewattachment/$aname_link?attach_id=$a[attachment_id]&amp;ticket_id=$enc_id" target="_blank">$img $aname - $a[attachment_type]</a></td>
            </tr>
EOF;
    }

    $comments = $comment->to_HTML( $r['comments'] );

    print <<<EOF
</table>
$comments
</td>
                </tr>
EOF;
  }
?>
                </tbody>
                </table>


 </td>
</tr>
</table>

<!-- End Comments Table -->
<!-- This is where the old assistance table went -->

      </td>
    </tr>
    </table>
  </td>
  <td background="../../img/console-vert-line-right.gif"><img alt="" src="../../img/cldot.gif" width="4" height="1" /></td>
</tr>
<tr>
  <td> <img alt="" src="../../img/console-btm-corn-left.gif" width="15" height="11" /></td>
  <td background="../../img/console-vert-line-btm.gif"><img alt="" src="../../img/cldot.gif" width="1" height="11" /></td>
  <td><img alt="" src="../../img/console-btm-corn-right.gif" width="14" height="11" /></td>
</tr>
</form>
</table>
<center>

