0

Hi,

Can anyone help me as to how I would handle recurring invoices in PHP I have it making invouices with a due date...

but say I wanted to mark an invoice to auto invoice every month... how would the script work and what data is needed to do that?

I know you can auto run the script to do it using Cron Jobs.... just cant get my head around it =)

Thanks for your help in advanced =)
Dan

1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Danny159
0

Ok, I have come up with something, can anyone clarify if this will work or now... the script will be run every day.

<?php
include("inc/config.php");

$inv_q = mysql_query("SELECT * FROM `invoices` WHERE `status` != '7'");
while($inv_r = mysql_fetch_assoc($inv_q)){
	
$recure = $inv_r['recure']; // EG + 1 month
$due_date = $inv_r['duedate']; // EG 1316361990

if($recure != NULL){	
	$mk_n_date = date("d/m/Y", strtotime($recure, $due_date));
	if($mk_n_date == date("d/m/Y")){
		// Mk new Inv
		echo "I made a new invoice!!<br>";
	}else{
		// Dont
		echo "I didnt make a new invoice<br>";
	}
}

unset($recure);
unset($due_date);
	
}
?>
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.