<?php

if(!defined('OSTCLIENTINC') || !$thisclient || !$ticket || !$ticket->checkUserAccess($thisclient)) die('Access Denied!');

?>

<h1>
    <?php echo sprintf(__('Editing Ticket #%s'), $ticket->getNumber()); ?>
</h1>

<form id="ticketEditForm"
      action="tickets.php"
      method="post"
      data-company-area-parent-var="CompanySourceTD"
      data-company-area-child-var="area"
      data-company-area-endpoint="ajax.php/company-area/children">
    <?php echo csrf_token(); ?>
    <input type="hidden" name="a" value="edit"/>
    <input type="hidden" name="id" value="<?php echo Format::htmlchars($_REQUEST['id']); ?>"/>
<table width="800">
    <tbody id="dynamic-form">
    <?php if ($forms)
        foreach ($forms as $form) {
            $form->render(['staff' => false]);
    } ?>
    </tbody>
</table>
<hr>
<p style="text-align: center;">
    <input type="submit" value="Update"/>
    <input type="reset" value="Reset"/>
    <input type="button" value="Cancel" onclick="javascript:
        window.location.href='index.php';"/>
</p>
</form>

<script type="text/javascript" src="js/company-area-dependency.js?v=1"></script>
<script type="text/javascript">
jQuery(function($) {
    if (window.CompanyAreaDependency
        && typeof window.CompanyAreaDependency.init === 'function') {
        window.CompanyAreaDependency.init('#ticketEditForm');
    }
});
</script>