function showFormForTask(Ticket $ticket, TicketTask $task)
 {
     global $CFG_GLPI, $LANG;
     $taskid = $task->getField('id');
     if ($taskid > 0 && $this->getFromDBbyTask($taskid)) {
         if ($this->canCreate()) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlan" . $taskid . "() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'users_id' => $this->fields["users_id"], 'id' => $this->fields["id"], 'state' => $this->fields["state"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'entity' => $ticket->fields["entities_id"]);
             ajaxUpdateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "}";
             echo "</script>\n";
             echo "<div id='plan' onClick='showPlan" . $taskid . "()'>\n";
             echo "<span class='showplan'>";
         }
         echo Planning::getState($this->fields["state"]) . "<br>" . convDateTime($this->fields["begin"]) . "<br>->" . convDateTime($this->fields["end"]) . "<br>" . getUserName($this->fields["users_id"]);
         if ($this->canCreate()) {
             echo "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         }
     } else {
         if ($this->canCreate()) {
             echo "<script type='text/javascript' >\n";
             echo "function showPlanUpdate() {\n";
             echo "Ext.get('plan').setDisplayed('none');";
             $params = array('form' => 'followups', 'state' => 1, 'users_id' => getLoginUserID(), 'entity' => $_SESSION["glpiactive_entity"]);
             ajaxUpdateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params);
             echo "};";
             echo "</script>";
             echo "<div id='plan'  onClick='showPlanUpdate()'>\n";
             echo "<span class='showplan'>" . $LANG['job'][34] . "</span>";
             echo "</div>\n";
             echo "<div id='viewplan'></div>\n";
         } else {
             echo $LANG['job'][32];
         }
     }
 }
along with GLPI; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--------------------------------------------------------------------------
*/
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
define('GLPI_ROOT', '..');
include GLPI_ROOT . "/inc/includes.php";
checkCentralAccess();
$task = new TicketTask();
if (isset($_POST["add"])) {
    $task->check(-1, 'w', $_POST);
    $task->add($_POST);
    Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . "  " . $LANG['log'][21]);
    glpi_header(getItemTypeFormURL('Ticket') . "?id=" . $task->getField('tickets_id'));
} else {
    if (isset($_POST["delete"])) {
        $task->check($_POST['id'], 'd');
        $task->delete($_POST);
        Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
        glpi_header(getItemTypeFormURL('Ticket') . "?id=" . $task->getField('tickets_id'));
    } else {
        if (isset($_POST["update"])) {
            $task->check($_POST["id"], 'w');
            $task->update($_POST);
            Event::log($task->getField('tickets_id'), "ticket", 4, "tracking", $_SESSION["glpiname"] . " " . $LANG['log'][21]);
            glpi_header($_SERVER['HTTP_REFERER']);
        }
    }
//add followup
if (isset($_REQUEST['ticketfollowup'])) {
    $fup = new TicketFollowup();
    if (isset($_POST["add"])) {
        $fup->check(-1, 'w', $_POST);
        $fup->add($_POST);
        Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a followup'), $_SESSION["glpiname"]));
    }
}
//add task
if (isset($_REQUEST['tickettask'])) {
    $ttask = new TicketTask();
    if (isset($_POST["add"])) {
        $ttask->check(-1, 'w', $_POST);
        $ttask->add($_POST);
        Event::log($ttask->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a task'), $_SESSION["glpiname"]));
    }
}
//add document
if (isset($_REQUEST['filename']) && !empty($_REQUEST['filename'])) {
    $doc = new Document();
    if (isset($_POST["add"])) {
        $doc->check(-1, 'w', $_POST);
        if ($newID = $doc->add($_POST)) {
            Event::log($newID, "documents", 4, "login", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $doc->fields["name"]));
        }
    }
}
//change ticket status
if (isset($_REQUEST['status']) && !empty($_REQUEST['status'])) {
    $ticket = new Ticket();