<link href="catalog/template/beststoreitems/css/ticket.css" type="text/css" rel="stylesheet" />
<link href="catalog/template/beststoreitems/css/page.css" type="text/css" rel="stylesheet" />
<script type="text/javascript">
function CheckForm(){
	var message=document.getElementById("message");
	if(message.value=="")    {
      alert("Message is not empty");
      return false;
    }else{
		document.getElementById('formDetail').submit();
	}
}
</script>
<div class="ticketBox">
    <div class="heading">My Ticket<s class="ordersIco"></s></div>
    <fieldset>
    	<legend><?php echo $ticket_data['ticket_no']?></legend>
        <table cellspacing="0" cellpadding="1" id="detail_ticket">
            <tbody>
                <tr><td class="ttop" colspan="4"></td></tr>
                <tr>
                    <td class="text-rhbold">Ticket ID</td>
                    <td><?php echo $ticket_data['ticket_no']?></td>
                    <td class="text-rhbold">Status</td>
                    <td><img src="https://www.beststoreitems.com/catalog/template/beststoreitems/image/<?php echo $ticket_data['status']==1?'enabled.png':'disabled.png'?>"></td>
                </tr>
                <tr>
                    <td class="text-rhbold">Date Created</td>
                    <td><?php echo $ticket_data['date_added']?></td>
                    <td class="text-rhbold">Last Responder</td>
                    <td><?php echo empty($last_ticket_info['staff'])?$customer_info['firstname'].' '.$customer_info['lastname']:$last_ticket_info['staff']?></td>
                </tr>
                <tr>
                    <td class="text-rhbold">Subject</td>
                    <td colspan="3"><?php echo $ticket_data['subject']?></td>
                </tr>
                <tr><td colspan="4" class="tspace"></td></tr>
            </tbody>
        </table>
        <div id="reply-form">
            <form action="index.php?controller=my_tickets&action=ticket_reply" id="formDetail" onsubmit="return CheckForm();" method="post">
                <textarea class="ticket_reply_form" name="message" id="message"></textarea>
                <input type="hidden" name="reference" value="<?php echo $ticket_data['reference']?>">
                <input type="hidden" name="ticket_id" value="<?php echo $ticket_data['ticket_id']?>">
                <div class="ticket-sub">
                    <input type="submit" value="Post Reply"  class="post_reply"  title="Post Reply"/>
                    <a href="/index.php?controller=my_ticket">Back to ticket list</a>
                </div>
            </form>

        </div>
           <form action="<?php echo $action; ?>" method="post" name="pageform" enctype="multipart/form-data">
		    <input type="hidden" name="page" value="1" />
		    <script type="text/javascript">
				 function SelectPage(page)
				 {
				    document.pageform.page.value = page;

				 	document.pageform.submit();

					return false;

		         };
			</script>
            <ul id="reply_box">
               <?php if(is_array($ticket_value_list)){?>
               <?php foreach($ticket_value_list as $tvl){?>
                <?php if(!empty($tvl['reply'])){?>
                <li class="content-box content-box-reply">
                    <div class="clearfix">
                    	<div class="message-name">
                        	<p class="message-me"></p>
                            <p><?php echo date($tvl['date_reply'])?></i></p>
                        </div>
                        <div class="message-info">
                        	<div class="cont"><?php echo $tvl['reply']?></div>
                        	 <?php if(!empty($tvl['reference'])){?>
                            <p class="tips">Order Number:
                            <?php if($tvl['order_status_type']==0){?>
                              <a target="_blank" class="order-num" href="<?php echo !empty($tvl['reference'])?'index.php?controller=potential_order&order_id='.$tvl['order_id'].'':'#'?>">
                            <?php }else{?>
                              <a target="_blank" class="order-num" href="<?php echo !empty($tvl['reference'])?'index.php?controller=account_invoice&order_id='.$tvl['order_id'].'':'#'?>">
                            <?php }?>
                            PO# <?php echo !empty($tvl['reference'])?$tvl['reference']:'None'?></a></p>
                            <?php }?>
                        </div>
                    </div>
                </li>
                <?php }?>
                <li class="content-box">
                    <div class="titckInfo clearfix">
                        <div class="message-name">
                            <p class="message-author"><?php echo $tvl['fullname']?>:</p>
                            <p><?php echo date($tvl['date_added'])?></p>
                        </div>
                        <div class="message-info">
                        	<div class="cont"><?php echo $tvl['message']?></div>
                        	 <?php if(!empty($tvl['reference'])){?>
                             <p class="tips">Order Number:
                            <?php if($tvl['order_status_type']==0){?>
                                 <a target="_blank" class="order-num" href="<?php echo !empty($tvl['reference'])?'index.php?controller=potential_order&order_id='.$tvl['order_id'].'':'#'?>">
                             <?php }else{?>
                                  <a target="_blank" class="order-num" href="<?php echo !empty($tvl['reference'])?'index.php?controller=account_invoice&order_id='.$tvl['order_id'].'':'#'?>">
                             <?php }?>
                             PO# <?php echo !empty($tvl['reference'])?$tvl['reference']:'None'?></a></p>
                             <?php }?>
                        </div>
                    </div>
                </li>

               <?php }?>
               <?php }?>
            </ul>
            <div class="page_wrapper">
                 <table width="100%">

			            <tr><td align="left"><?php echo $text_results; ?></td>

			            <td align="right">

			          <table cellspacing="0" cellpadding="0" class="page">

			            <tr>

			            <?php if ($page>1) { ?>

			            <td id="page_box_previous"><a href="#" onclick="return SelectPage(<?php echo ($page-1); ?>);"><?php echo 'Previous'?></a></td>

			            <?php };

			            foreach ($pages as $pageentry) {

			                    if ( $pageentry['value'] > ($page + max(9-$page,4)) ) {?>

			                               <td id="page_box_next"><a href="#" onclick="return SelectPage(<?php echo ($page+1); ?>);"><?php echo 'Next'?></a></td>

			                    <?php

			                         break;

			                     } ;



			                    if ( $pageentry['value'] < ($page - 4) ) {continue; }

			                    ?>



			                    <?php if ($pageentry['value'] == $page) { ?>

			                    <td width="20" height="16" align="center" valign="middle"><b class="current_i"><font size="1"><?php $x = explode(" ",$pageentry['text']);echo $x[0]; ?></font></b></td>

			                    <?php } else { ?>

			                    <td id="page_box" >

			                    <a href="#" onclick="return SelectPage(<?php echo $pageentry['value']; ?>);"><?php $x = explode(" ",$pageentry['text']);echo $x[0]; ?></a></td>

			                    <?php } ?>

			            <?php } ?>
			            <td>Go to Page
			                <select onchange="return SelectPage(this.value)" style="width:50px;">
			                    <?php foreach ($pages as $pageentry){?>
			                        <option value="<?php echo $pageentry['value']?>" <?php if ($pageentry['value'] == $page){echo 'selected';}?>><?php echo $pageentry['value']?></option>
			                    <?php };?>
			                </select>
			            </td>
			          </tr></table>

			    </td></tr></table>
            </div>
     	</form>
     </fieldset>
</div>
