This topic is locked

Checkbox updates Date fields again a few days later

9/19/2008 1:23:46 PM
PHPRunner General questions
S
swanside author

At the moment I have used this code

if ($values["Invoice_Printed"])

$values["Invoice_Printed_Date"] = Now();


Problem is, This is on the edit page.
I also have on the edit page, Job_Finished and Payment_Received
I go to the edit page and tick the checkbox for invoice printed, the correct date appears in the Invoice_Printed_Date as 17 September 2008
I go to the edit page on the 19 September 2008 and tick the Payment_Received checkbox and the date of 19 September 2008 appears in the Payment_Received box, but when I save it, the date changes on the Invoice_Printed_Date to the 19 September 2008 and does not stay as 18 September 2008.
Is there a way around this please
Thanks

Paul

T
thesofa 9/20/2008

change the first IF condition so it check, as you have, to see if there is a value in the Invoice_Printed field, but also check to make sure that the Invoice_Printed_Date field is empty, then peform the

$values["Invoice_Printed_Date"] = Now();



so a line like

if (($values["Invoice_Printed"]) AND (!$values["Invoice_Printed_Date"]))

$values["Invoice_Printed_Date"] = Now();


That SHOULD check for the 2 conditions and only set the date if true.

HTH

S
swanside author 9/20/2008

change the first IF condition so it check, as you have, to see if there is a value in the Invoice_Printed field, but also check to make sure that the Invoice_Printed_Date field is empty, then peform the

$values["Invoice_Printed_Date"] = Now();



so a line like

if (($values["Invoice_Printed"]) AND (!$values["Invoice_Printed_Date"]))

$values["Invoice_Printed_Date"] = Now();


That SHOULD check for the 2 conditions and only set the date if true.

HTH


Thank you so much for that, works a treat.
Thanks
Paul

S
swanside author 9/20/2008

Thanks, I ended up combining your help and Janes and now its great
I used this

if (($values["Invoice_Printed"]) AND (!$values["Invoice_Printing_Date"]))

$values["Invoice_Printing_Date"] = Now();
if (($values["Invoice_Printed"]) AND (!$values["Invoice_Tax_Date"]))

$values["Invoice_Tax_Date"] = Now();
if (($values["Invoice_Printed"]) AND (!$values["Payment_Due_date"]))

$values["Payment_Due_date"] = date("Y-m-d",strtotime("+30 day"));
return true;


Thanks

T
thesofa 9/21/2008

So when you tick the Invoice_Printed field, it puts the date in for Invoice_Printing_Date and also for Invoice_Tax_Date and then adds 30 days to the invoice printed date fro the due date?

S
swanside author 9/21/2008

So when you tick the Invoice_Printed field, it puts the date in for Invoice_Printing_Date and also for Invoice_Tax_Date and then adds 30 days to the invoice printed date fro the due date?


Yeh.
I know this might sound daft, but I am really pleased over this.
Saves alot of date selecting.