function printing_commands()
{
    $output = '';
    $sourceid = $_SESSION['sourceid'];
    if (printing_orders_to_print($sourceid)) {
        $output .= '<a href="orders.php?command=print_orders">' . ucfirst(phr('PRINT_ORDERS')) . '</a><br />' . "\n";
        $output .= '<br />';
    }
    if (printing_orders_printed_category(2)) {
        $output .= '<a href="orders.php?command=print_category&amp;data[category]=2">' . ucfirst(phr('PRINT_GO_2')) . '</a><br />' . "\n";
        $output .= '<br />';
    }
    if (printing_orders_printed_category(3)) {
        $output .= '<a href="orders.php?command=print_category&amp;data[category]=3">' . ucfirst(phr('PRINT_GO_3')) . '</a><br />' . "\n";
        $output .= '<br />';
    }
    if (bill_orders_to_print($_SESSION['sourceid'])) {
        $output .= "<a href=\"orders.php?command=bill_select\">" . ucfirst(phr('PRINT_SEPARATED_BILLS')) . "</a><br />\n";
    }
    $user = new user($_SESSION['userid']);
    if ($user->level[USER_BIT_CASHIER]) {
        $output .= '
	<br />
	<a href="orders.php?command=bill_reset">(' . ucfirst(phr('RESET_SEPARATED')) . ')</a><br />
	<br />
	';
        if (bill_orders_to_print($_SESSION['sourceid'])) {
            $output .= '
	<a href="orders.php?command=bill_select_all">' . ucfirst(phr('PRINT_BILL')) . '</a><br />
	';
        }
    }
    return $output;
}
function dish_list_pos($start_data)
{
    global $tpl;
    $_SESSION['order_added'] = 0;
    $tpl->set_waiter_template_file('dishlist');
    $tmp = navbar_empty_pos();
    if (printing_orders_to_print($_SESSION['sourceid'])) {
        $tmp = navbar_with_printer_pos();
    } else {
        $tmp = navbar_empty_pos();
    }
    $tpl->assign('navbar', $tmp);
    if (get_conf(__FILE__, __LINE__, "show_summary") && isset($_SESSION['go_back_to_cat']) && $_SESSION['go_back_to_cat']) {
        $tbl = new table($_SESSION['sourceid']);
        if ($last_mod = order_get_last_modified()) {
            $mods = get_conf(__FILE__, __LINE__, "show_mods_in_summary");
            $tbl->list_orders_pos('last_order', $last_mod, $mods);
        }
    }
    if (isset($start_data['category'])) {
        $tmp = dishlist_form_start($back_to_cat);
        $tpl->assign('formstart', $tmp);
        $tmp = dishlist_form_end();
        $tpl->assign('formend', $tmp);
        $tmp = dishlist_back_to_cat();
        $tpl->assign('back_to_cat', $tmp);
        $tmp = priority_radio($start_data);
        $tpl->assign('priority', $tmp);
        $tmp = quantity_list($start_data);
        $tpl->assign('quantity', $tmp);
        $tmp = dishes_list_cat_pos($start_data);
        $tpl->assign('dishes_list', $tmp);
    } elseif (isset($start_data['letter'])) {
        $tmp = dishlist_form_start(false);
        $tpl->assign('formstart', $tmp);
        $tmp = dishlist_form_end();
        $tpl->assign('formend', $tmp);
        $tmp = priority_radio($start_data);
        $tpl->assign('priority', $tmp);
        $tmp = quantity_list($start_data);
        $tpl->assign('quantity', $tmp);
        $tmp = dishes_list_letter($start_data);
        $tpl->assign('dishes_list', $tmp);
    } elseif (isset($start_data['search'])) {
        $tmp = dishlist_form_start(false);
        $tpl->assign('formstart', $tmp);
        $tmp = dishlist_form_end();
        $tpl->assign('formend', $tmp);
        $tmp = priority_radio($start_data);
        $tpl->assign('priority', $tmp);
        $tmp = quantity_list($start_data);
        $tpl->assign('quantity', $tmp);
        $tmp = dishes_list_search($start_data);
        $tpl->assign('dishes_list', $tmp);
    } elseif (isset($start_data['idsystem'])) {
        $tmp = dishlist_form_start(false);
        $tpl->assign('formstart', $tmp);
        $tmp = dishlist_form_end();
        $tpl->assign('formend', $tmp);
        $tmp = priority_radio($start_data);
        $tpl->assign('priority', $tmp);
        $tmp = quantity_list($start_data);
        $tpl->assign('quantity', $tmp);
        $tmp = input_dish_id($start_data);
        $tpl->assign('dishes_list', $tmp);
    } else {
        $tmp = categories_list_pos($start_data);
        $tpl->assign('categories', $tmp);
        $tmp = ucfirst(phr('ERROR_NO_CATEGORY_SELECTED')) . "<br/>\n";
        $tpl->append('messages', $tmp);
    }
    return 0;
}
/**
* Closes a table
*
* @param integer $sourceid
* @return integer error code
*/
function table_close($sourceid)
{
    global $tpl;
    $query = "SELECT * FROM `sources` WHERE `id` = '{$sourceid}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    if (!mysql_num_rows($res)) {
        return ERR_TABLE_NOT_FOUND;
    }
    $query = "UPDATE `sources` SET `toclose`='1' WHERE `id` = '{$sourceid}'";
    $res = common_query($query, __FILE__, __LINE__);
    if (!$res) {
        return ERR_MYSQL;
    }
    $print = false;
    if (get_conf(__FILE__, __LINE__, "print_remaining_tickets_anyway")) {
        $print = true;
    } elseif (table_is_takeaway($sourceid) && get_conf(__FILE__, __LINE__, "print_remaining_tickets_if_takeaway")) {
        $print = true;
    }
    if ($print && printing_orders_to_print($sourceid)) {
        $err = print_orders($sourceid);
        status_report('ORDERS_PRINT', $err);
    }
    return 0;
}