We're trying to fix the PHP code (from php programmer who was fired few weeks ago) to make sure these dates does not exceed more than 28 days on the form.
When the customer fills out the application on the https://www.sorensonvrs.com/international_travel_request and they fill it out over 28 days - it fails.
PHP -
if ($valid_departure_date == TRUE && $valid_return_date == TRUE) {
$submit_date = intval(date("Ymd")); // Today's date
$departure_date_string = sprintf("%02d",$post['departureYear']).sprintf("%02d",$post['departureMonth']).sprintf("%02d",$post['departureDay']);
$departure_date = intval($departure_date_string);
$return_date_string = sprintf("%02d",$post['returnYear']).sprintf("%02d",$post['returnMonth']).sprintf("%02d",$post['returnDay']);
$return_date = intval($return_date_string);
if ($departure_date > $return_date) {
// $this->errors += array('depGTRet' => 'required');
$this->errors = $post->errors();
$post->add_error('depGTRet','required');
$this->valid = '';
} else {
if ($submit_date >= $departure_date) {
// $this->errors += array('oldDates' => 'required');
$post->add_error('oldDates','required');
$this->errors = $post->errors();
$this->valid = '';
} else {
$trip_departure_date = substr($departure_date,0,4) . '-' . substr($departure_date,4,2) . '-' . substr($departure_date,6,2);
$trip_return_date = date_create($trip_departure_date);
date_add($trip_return_date,date_interval_create_from_date_string("28 days"));
$trip_return_date = intval(date_format($trip_return_date,"Ymd"));
if ($return_date >= $trip_return_date) {
// $this->errors += array('checkDates' => 'required');
$this->errors = $post->errors();
$post->add_error('checkDates','required');
$this->valid = '';
} else {
$validated_dates = TRUE;
}
}
}
}
We're not a math whiz, but these calculation in PHP is confusing us. Thank you!