Skip to content

Commit

Permalink
update invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
o-psi committed Oct 14, 2023
1 parent 7a6c3ec commit 0270a68
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions database_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -1405,13 +1405,29 @@
// Please add this same comment block to the bottom of this file, and update the version number.
// Uncomment Below Lines, to add additional database updates
//
//if (CURRENT_DATABASE_VERSION == '0.8.8') {
if (CURRENT_DATABASE_VERSION == '0.8.8') {
// Insert queries here required to update to DB version 0.8.9
// mysqli_query($mysqli, "ALTER TABLE `invoice_items` ADD `item_order_id` INT(11) NOT NULL DEFAULT 0 AFTER `item_total`");
mysqli_query($mysqli, "ALTER TABLE `invoice_items` ADD `item_order_id` INT(11) NOT NULL DEFAULT 0 AFTER `item_total`");
// Update existing invoices so that item_order_id is set to item_id
$sql_invoices = mysqli_query($mysqli, "SELECT invoice_id FROM invoices WHERE invoice_id IS NOT NULL");
foreach ($sql_invoices as $row) {
$invoice_id = $row['invoice_id'];
$sql_invoice_items = mysqli_query($mysqli, "SELECT item_id FROM invoice_items WHERE item_invoice_id = '$invoice_id' ORDER BY item_id ASC");
$item_order_id = 1;
foreach ($sql_invoice_items as $row) {
$item_id = $row['item_id'];
mysqli_query($mysqli, "UPDATE invoice_items SET item_order_id = '$item_order_id' WHERE item_id = '$item_id'");
$item_order_id++;
//Log changes made to invoice
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Invoice', log_action = 'Modify', log_description = 'Updated item_order_id to item_id: $item_order_id'");

}
}

//
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.9'");
//}
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.8.9'");
}
//

} else {
Expand Down

0 comments on commit 0270a68

Please sign in to comment.