dol_include_once('/pos/class/ticket.class.php');
require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php';
require_once DOL_DOCUMENT_ROOT . "/core/lib/functions2.lib.php";
dol_include_once('/pos/backend/lib/ticket.lib.php');
$langs->load("pos@pos");
// Security check
$ticketid = isset($_GET["ticketid"]) ? $_GET["ticketid"] : '';
if ($user->societe_id) {
    $socid = $user->societe_id;
}
if (!$user->rights->pos->backend) {
    accessforbidden();
}
/*
 * View
 */
$helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:Módulo_DoliPos';
llxHeader('', '', $helpurl);
$ticket = new Ticket($db);
$ticket->fetch($_GET["id"]);
$ticket->info($_GET["id"]);
$soc = new Societe($db, $ticket->socid);
$soc->fetch($ticket->socid);
$head = ticket_prepare_head($ticket);
dol_fiche_head($head, 'info', $langs->trans("Ticket"), 0, 'ticket');
print '<table width="100%"><tr><td>';
dol_print_object_info($ticket);
print '</td></tr></table>';
print '</div>';
llxFooter();
$db->close();
if (GETPOST('action', 'string') == 'confirm_factureticket') {
    $result = $object->create_facture();
    setEventMessage($langs->trans("BillWasCreated"));
    //Header('Location: '.DOL_URL_ROOT.'/compta/facture.php?facid='.$result);
}
if (GETPOST('action', 'string') == 'reopen') {
    $result = $object->set_unpaid();
    Header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $id);
}
/*
 * View
 */
$helpurl = 'EN:Module_DoliPos|FR:Module_DoliPos_FR|ES:M&oacute;dulo_DoliPos';
llxHeader('', $langs->trans('Ticket'), $helpurl);
$result = $object->fetch($id, $ref);
$head = ticket_prepare_head($object);
dol_fiche_head($head, 'ticket', $langs->trans("Ticket"), 0, 'ticket');
$html = new Form($db);
$htmlother = new FormOther($db);
$formfile = new FormFile($db);
$now = dol_now();
if ($result > 0) {
    if ($user->societe_id > 0 && $user->societe_id != $object->socid) {
        accessforbidden('', 0);
    }
    $result = $object->fetch_thirdparty();
    $soc = new Societe($db, $object->socid);
    $soc->fetch($object->socid);
    print '<table class="border" width="100%">';
    // Ref
    print '<tr>';