1 Commits

4 changed files with 30 additions and 23 deletions

View File

@@ -121,17 +121,21 @@ class RecoRecoModel extends Base
// Default off: only keep the duplicate link when explicitly turned on. // Default off: only keep the duplicate link when explicitly turned on.
$linkCopies = isset($meta['recoreco_link_copies']) && $meta['recoreco_link_copies'] == 1; $linkCopies = isset($meta['recoreco_link_copies']) && $meta['recoreco_link_copies'] == 1;
// Finite-plan stop. RecoReco caps its own recurrence: either by its own limit (standalone), // Finite-plan stop. RecoReco caps its own recurrence, either by its own limit (standalone) or
// or by following FinanceBuddy's installment total. In follow mode both numbers are read LIVE // by following FinanceBuddy. When follow is on, FinanceBuddy governs: the plan is finite only
// from FinanceBuddy (never copied into RecoReco), so a mid-plan start, a re-purchase, or an // if the card has a numeric installment total, so an ordinary recurring bill (money but no
// extend all just work by editing FinanceBuddy. A blank/0 limit means recur forever. The // installments) recurs forever -- and any stale standalone limit is ignored. In follow mode
// spawn loop below stops when counter > limit (1-based; the counter ends on limit+1). // the numbers are read LIVE from FinanceBuddy (never copied), so a mid-plan start, a
// re-purchase, or an extend all just work by editing FinanceBuddy. A blank/0 limit means
// recur forever. The spawn loop below stops when counter > limit (1-based; counter ends on
// limit+1).
$followIntent = isset($meta['recoreco_follow_finance']) && $meta['recoreco_follow_finance'] == 1;
$fbTotal = isset($meta['financebuddy_installment_total']) ? (string) $meta['financebuddy_installment_total'] : ''; $fbTotal = isset($meta['financebuddy_installment_total']) ? (string) $meta['financebuddy_installment_total'] : '';
$follow = isset($meta['recoreco_follow_finance']) && $meta['recoreco_follow_finance'] == 1 $fbHasTotal = $fbTotal !== '' && ctype_digit($fbTotal);
&& $fbTotal !== '' && ctype_digit($fbTotal); $follow = $followIntent && $fbHasTotal;
if ($follow) { if ($followIntent) {
$limit = (int) $fbTotal; $limit = $fbHasTotal ? (int) $fbTotal : 0; // following FinanceBuddy; no total => forever
} else { } else {
$limitRaw = isset($meta['recoreco_limit']) ? (string) $meta['recoreco_limit'] : ''; $limitRaw = isset($meta['recoreco_limit']) ? (string) $meta['recoreco_limit'] : '';
$limit = ($limitRaw !== '' && ctype_digit($limitRaw)) ? (int) $limitRaw : 0; $limit = ($limitRaw !== '' && ctype_digit($limitRaw)) ? (int) $limitRaw : 0;

View File

@@ -62,7 +62,7 @@ class Plugin extends Base
public function getPluginVersion() public function getPluginVersion()
{ {
return '1.6.1'; return '1.6.2';
} }
public function getPluginHomepage() public function getPluginHomepage()

View File

@@ -63,26 +63,29 @@
<p class="form-help"><?= t('Links each copy back to the template (a count and quick navigation). Off by default.') ?></p> <p class="form-help"><?= t('Links each copy back to the template (a count and quick navigation). Off by default.') ?></p>
<?php $following = $fb_enabled && $values['recoreco_follow_finance'] == 1 ?> <?php $following = $fb_enabled && $values['recoreco_follow_finance'] == 1 ?>
<?php $limit_display = (int) $values['recoreco_limit'] > 0 ? (int) $values['recoreco_limit'] : '' ?>
<div class="recoreco-limit-group" <div class="recoreco-limit-group"
data-fb-current="<?= $this->text->e($fb_current === '' ? '1' : $fb_current) ?>" data-fb-current="<?= $this->text->e($fb_current) ?>"
data-fb-total="<?= $this->text->e($fb_total === '' ? '0' : $fb_total) ?>" data-fb-total="<?= $this->text->e($fb_total) ?>"
data-rr-count="<?= (int) $values['recoreco_count'] ?>" data-rr-count="<?= (int) $values['recoreco_count'] ?>"
data-rr-limit="<?= (int) $values['recoreco_limit'] ?>"> data-rr-limit="<?= $this->text->e($limit_display) ?>">
<?php if ($fb_enabled): ?> <?php if ($fb_enabled): ?>
<?= $this->form->checkbox('recoreco_follow_finance', t('Follow FinanceBuddy installments'), 1, $following) ?> <?= $this->form->checkbox('recoreco_follow_finance', t('Follow FinanceBuddy installments'), 1, $following) ?>
<p class="form-help"><?= t('Stop recurring when the installment plan ends, following the card total and current installment.') ?></p> <p class="form-help"><?= t('Stop recurring when the installment plan ends, following the card total and current installment.') ?></p>
<?php endif ?> <?php endif ?>
<?= $this->form->label(t('Current recurrence'), 'recoreco_count') ?> <?= $this->form->label(t('Recurrence'), 'recoreco_count') ?>
<input type="number" name="recoreco_count" min="1" <div class="recoreco-limit-inline" style="display:flex; align-items:center; gap:6px;">
value="<?= $this->text->e($following ? ($fb_current === '' ? '1' : $fb_current) : $values['recoreco_count']) ?>" <input type="number" name="recoreco_count" min="1" style="width:5em;"
<?= $following ? 'disabled="disabled"' : '' ?>> value="<?= $this->text->e($following ? $fb_current : $values['recoreco_count']) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>>
<?= $this->form->label(t('Stop after this many recurrences (0 = never)'), 'recoreco_limit') ?> <span><?= t('of') ?></span>
<input type="number" name="recoreco_limit" min="0" <input type="number" name="recoreco_limit" min="1" style="width:5em;"
value="<?= $this->text->e($following ? ($fb_total === '' ? '0' : $fb_total) : $values['recoreco_limit']) ?>" value="<?= $this->text->e($following ? $fb_total : $limit_display) ?>"
<?= $following ? 'disabled="disabled"' : '' ?>> <?= $following ? 'disabled="disabled"' : '' ?>>
</div>
<p class="form-help"><?= t('Current recurrence and how many to run. Leave the second box empty to recur forever.') ?></p>
</div> </div>
<?= $this->modal->submitButtons() ?> <?= $this->modal->submitButtons() ?>

View File

@@ -1 +1 @@
RecoReco v1.6.1 RecoReco v1.6.2