0

Hi,

I am trying very hard to make my own recurring invoice script.

I simply have a field where the invoice date is entered.

I just want to check if the date is equal to the date+1year ahead of time.

If so then run the rest of the php to send email attach PDF and etc...

After which i will update the date table with the next current date.

///////////////////////////////  begin query //////////////////////////

$recurrQuery = "SELECT date FROM invoices_recurring WHERE status=1";
$recurrResult = mysql_query($recurrQuery);
while ($recurrRow = mysql_fetch_array($recurrResult)) { 
$recurrDate = $recurrRow['date']; 
}

if( $recurrDate = $recurrDate(strtotime("+365 day") ) ) {

process invoice script here 

} else {

the invoice isnt 1year old

}

Or is there an easier way?

Maybe i could INSERT the invoice creation date with the year already added to it and do a different query?

Any help would be appreciated please :-)

Regards
John

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jonnypixel
0

Hi,

I am trying very hard to make my own recurring invoice script.

I simply have a field where the invoice date is entered.

I just want to check if the date is equal to the date+1year ahead of time.

If so then run the rest of the php to send email attach PDF and etc...

After which i will update the date table with the next current date.

///////////////////////////////  begin query //////////////////////////

$recurrQuery = "SELECT date FROM invoices_recurring WHERE status=1";
$recurrResult = mysql_query($recurrQuery);
while ($recurrRow = mysql_fetch_array($recurrResult)) { 
$recurrDate = $recurrRow['date']; 
}

if( $recurrDate = $recurrDate(strtotime("+365 day") ) ) {

process invoice script here 

} else {

the invoice isnt 1year old

}

Or is there an easier way?

Maybe i could INSERT the invoice creation date with the year already added to it and do a different query?

Any help would be appreciated please :-)

Regards
John

Hey,

Ok i think i answered my own question.

It probably isnt the most elaborate way but i think i can make it work.

To add the recurring invoice i need the variable

$dateOneYearAdded

from this code:

<?php
$currentDate = date("Y-m-d");// current date

echo "Current Date: ".date("d-m-Y", strtotime($getDate))."<br><br>";

//Add one year to current date
$dateOneYearAdded = strtotime(date("d-m-Y", strtotime($currentDate)) . " +1 year");

echo "Date After adding one year: ".date('l dS \o\f F Y', $dateOneYearAdded)."<br><br><hr><br>";

echo date("d-m-Y", $dateOneYearAdded)." :: Send this entry to the DB when creating a recurring invoice. The variable to insert is <b>dateOneYearAdded</b><br><br>Then i can do a query on the date from the database and compare it to todays date. If they match up then run the script to email an invoice and attach pdf etc..";
?>

Then i can simply query the database and check if the Date stored in the MYSQL field is equal to todays date.

This would of course run in a daily cron script and i may need to make sure there are some other variables checked etc.. but i think i got it.

If anyone knows a much better way then please do share.

John

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.