<?php
// Copyright (C) 2023 Kris Occhipinti
// https://filmsbykris.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU Affero General Public
// License as published by the Free Software Foundation; 
// version 3 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Affero General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
// https://www.gnu.org/licenses/agpl-3.0.txt
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename="tshirt-orders.csv"');
$db = new SQLite3('db/orders.db');
$results = $db->query('SELECT * FROM orders');
$data = array();
echo "Order Number,Name,Email,s,m,l,xl,xxl,picked up,paid,style,xxxl,xxxxl\n";
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
echo implode(array_values($row), ",") . "\n";
}

?>
