Autoresponder off by a day problem

Discussion in 'Troubleshooting' started by hebrew, Apr 11, 2011.

  1. hebrew

    hebrew New Member

    Joined:
    Aug 3, 2009
    Messages:
    9
    We have set up autoresponders to send out depending on the number of days a person has had a subscription for (if they have had a number of subscriptions we have set it to total up the number of days they have been around for, and send out the email depending on that day).

    It has come to our attention that the code to send out emails based on the number of days might be incorrect.
    For example - if person A signs up for a month (say April 1 - April 30th) - then stops and then in 2 months time signs up for another month (June 1- June 30th) - they should be on day 30 when they start again. But the software cacluates finished day - starting day which is 30-1 = 29 and then when they start again (1-1 ) = 0 so the day they start will be day 29, but really it should be day 30, so it gets pushed off by a day each time they stop their subscription and then start again.

    I am basing this on the code:
    $q = $db->query($s = "SELECT m.*
    FROM {$db->config['prefix']}members m
    LEFT JOIN {$db->config['prefix']}payments p USING (member_id)
    WHERE p.completed > 0
    AND p.begin_date <= '$today' $product_where
    GROUP BY m.member_id
    HAVING
    SUM(to_days(if(p.expire_date>'$today', '$today', p.expire_date)) - to_days(p.begin_date)) = $days
    AND
    MAX(p.expire_date) >= '$today'
    "); }

    Am I understanding this correctly?

    Thanks,
    Leora
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Yes this seems to be a bug. Contact us in helpdesk I will send fixed file for your version.

Share This Page