First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
include "db.php";
|
||||
include "table.php";
|
||||
|
||||
|
||||
$school_num = readline("School Number: ");
|
||||
$school_num = intval($school_num);
|
||||
|
||||
$school_name = db_getVal("SELECT school_name FROM schools WHERE record_num = $school_num");
|
||||
$x = readline("$school_name - Continue... ");
|
||||
|
||||
echo("\n");
|
||||
|
||||
$schedule_num = readline("Schedule Number: ");
|
||||
$schedule_num = intval($schedule_num);
|
||||
|
||||
$schedule_title = db_getVal("SELECT schedule_name FROM hotlunch_schedules WHERE school_num = $school_num AND record_num = $schedule_num");
|
||||
$x = readline("$schedule_title - Continue... ");
|
||||
|
||||
echo("\n");
|
||||
|
||||
$DB = "hotlunch_".date("Ymd",time() - 60 * 60 * 24);
|
||||
$x = readline("Use database $DB - Continue... ");
|
||||
|
||||
db_query("USE $DB");
|
||||
|
||||
|
||||
$concession = db_getVal("SELECT record_num FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND ordered_by_type = 'Concession'");
|
||||
|
||||
|
||||
$query = "SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND ordered_by_type != 'Concession'";
|
||||
$results = db_query($query);
|
||||
$Orders = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$Orders[] = $row;
|
||||
}
|
||||
|
||||
|
||||
$query = "SELECT * FROM hotlunch_order_items WHERE school_num = $school_num AND schedule_num = $schedule_num AND order_num != $concession";
|
||||
$results = db_query($query);
|
||||
$Items = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$Items[] = $row;
|
||||
}
|
||||
|
||||
|
||||
$query = "SELECT * FROM user_account WHERE school_num = $school_num AND schedule_num = $schedule_num AND transaction_type = 'Order'";
|
||||
$results = db_query($query);
|
||||
$Transactions = array();
|
||||
while ($row = db_fetch_assoc($results)) {
|
||||
$Transactions[] = $row;
|
||||
}
|
||||
|
||||
|
||||
echo("Orders: ".count($Orders)."\n");
|
||||
echo("Items: ".count($Items)."\n");
|
||||
echo("Transactions: ".count($Transactions)."\n");
|
||||
|
||||
$x = readline("Continue ");
|
||||
|
||||
|
||||
db_query("USE hotlunch");
|
||||
|
||||
|
||||
$Duplicates = array();
|
||||
for ($i = 0; $i < count($Orders); $i++) {
|
||||
$row = $Orders[$i];
|
||||
$ordered_by_num = $row['ordered_by_num'];
|
||||
|
||||
$query = "SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND ordered_by_num = $ordered_by_num";
|
||||
$r = db_query($query);
|
||||
if (db_num_rows($r)) {
|
||||
$name = db_getVal("SELECT concat(first_name,' ',last_name) FROM people WHERE record_num = $ordered_by_num");
|
||||
echo("DUPLICATE ORDER: $name ($ordered_by_num)\n");
|
||||
$Duplicates[] = $ordered_by_num;
|
||||
}
|
||||
}
|
||||
|
||||
echo("Duplicates: ".count($Duplicates)."\n");
|
||||
$x = readline("Continue ");
|
||||
|
||||
|
||||
$order_count = 0;
|
||||
$oTable = new Table("hotlunch_order_header");
|
||||
for ($i = 0; $i < count($Orders); $i++) {
|
||||
$row = $Orders[$i];
|
||||
|
||||
if (count($Duplicates) == 0 || !in_array($row['ordered_by_num'], $Duplicates)) {
|
||||
$query = $oTable->BuildInsert($row,'Yes');
|
||||
db_query($query);
|
||||
$order_count++;
|
||||
echo(" $order_count\r");
|
||||
}
|
||||
}
|
||||
|
||||
echo("Orders entered: $order_count\n");
|
||||
$x = readline("Continue ");
|
||||
|
||||
|
||||
$item_count = 0;
|
||||
$iTable = new Table("hotlunch_order_items");
|
||||
for ($i = 0; $i < count($Items); $i++) {
|
||||
$row = $Items[$i];
|
||||
|
||||
if (count($Duplicates) == 0 || !in_array($row['ordered_by_num'], $Duplicates)) {
|
||||
$query = $iTable->BuildInsert($row,'No');
|
||||
db_query($query);
|
||||
$item_count++;
|
||||
echo(" $item_count\r");
|
||||
}
|
||||
}
|
||||
|
||||
echo("Order items entered: $item_count\n");
|
||||
$x = readline("Continue ");
|
||||
|
||||
|
||||
$trx_count = 0;
|
||||
$tTable = new Table("user_account");
|
||||
for ($i = 0; $i < count($Transactions); $i++) {
|
||||
$row = $Transactions[$i];
|
||||
$query = $tTable->BuildInsert($row,'No');
|
||||
db_query($query);
|
||||
$trx_count++;
|
||||
echo(" $trx_count\r");
|
||||
}
|
||||
|
||||
echo("transactions entered: $trx_count\n");
|
||||
|
||||
$query = "DELETE FROM user_account WHERE school_num = $school_num AND schedule_num = $schedule_num AND transaction_type = 'TRX Note' AND note LIKE 'Schedule Order Deletion%'";
|
||||
db_query($query);
|
||||
|
||||
|
||||
?>
|
||||
Reference in new issue
Block a user