I am trying to write a code that will allow user activate item and adjust expiration date if needed.
I have three variables:
Project Date: $proj
Item Date: $item
Today: $now
Ideally a project is created first, then item. Project date can not be less then $item date.
So if an item is expired $item< $now the user can reactivate it, but at this point I need to look at the $proj date because it can never be less then item's date $proj > $item unless $proj == 0;
It should be quite simple but I'm afraid I'm missing something. Seems like my code grows exponentially with all options although I have a feeling it should be "smarter" rather then writing a condition for every possible combination... Need more coffee.
if ($item < $proj < $now && $proj != 0) {
// adjust $item date and activate $item
} elseif ($item < $now < $proj && $proj != 0) {
// adjust $item and $proj dates and activate $item
} elseif ($item > $proj && $proj != 0) {
// adjust $item and $proj dates and activate $item
} else {
// activate $item
}