Files
itflow/admin/database_updates/4.3.7.php

33 lines
1.9 KiB
PHP

<?php
/*
* ITFlow - Database update to version 4.3.7 (from 4.3.6)
* Included by admin/database_updates.php - do not access directly
*
* settings.config_invoice_offer_autopay - whether an invoice from a recurring invoice with no autopay offers the
* client a Set up autopay button, in its email and on its page (1, Settings > Invoices > Paid online), when
* card payments are on. The button opens a page that needs no sign-in: the client agrees, adds a card through
* Stripe, and each invoice from then on is charged on its due date.
* recurring_invoices.recurring_invoice_offer_autopay - the same for one recurring invoice (1), turned off on its
* page for a client who pays another way.
*
* Both start on. Re-runnable: each column is made only where it isn't there.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
$itflow_offer_columns = [
'settings' => ['config_invoice_offer_autopay', 'config_invoice_paid_lead_to_client'],
'recurring_invoices' => ['recurring_invoice_offer_autopay', 'recurring_invoice_email_notify'],
];
foreach ($itflow_offer_columns as $itflow_table => [$itflow_column, $itflow_after]) {
$itflow_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$itflow_table' AND COLUMN_NAME = '$itflow_column' LIMIT 1");
if (!$itflow_exists || mysqli_num_rows($itflow_exists) === 0) {
$itflow_after_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$itflow_table' AND COLUMN_NAME = '$itflow_after' LIMIT 1");
$itflow_place = $itflow_after_exists && mysqli_num_rows($itflow_after_exists) > 0 ? " AFTER `$itflow_after`" : '';
mysqli_query($mysqli, "ALTER TABLE `$itflow_table` ADD `$itflow_column` tinyint(1) NOT NULL DEFAULT 1$itflow_place");
}
}