Menu
Index > Helpers

todoValueLate

todoValueLate($todo_value, $options = array())

Description:
Returns Boolean:
- true the TodoValue is late because the due date is today or past and the TodoValue has not been validated and optionally approved; false the Todo(Value) is not late because the due date is tomorrow or further into the future.

Options:
(array) $todo_value - the TodoValue with 'TodoValue' as an array key.
(array) $options - not employed.

Example:
//
$todoValueLate = $this->Deals->todoValueLate($todo_value);
//
echo 'This Todo is ' . ($todoValueLate ? 'late' : 'on time') . '.';

/**
 * Late - due date is today or earlier; approval has not been given.
 * 
 * 
 * @params	$data TodoValue
 * @params	$options
 * @return        Boolean
 */
	public function todoValueLate($data, $options = array()) {
		//
		$return		= false;
		//
		if (!$data) {
			//
			return	$return;
		}
		//
		$data		= isset($data[$this->alias][$this->primaryKey]) && strlen($data[$this->alias][$this->primaryKey]) > 0
				? $data[$this->alias]
				: $data;
		//
		$due_date	= date('Y-m-d', strtotime($data['due_date']));
		//
		$today		= date('Y-m-d');
		//
		$return		= $due_date <= $today && !$this->todoValueDone($data);
		//
		return		$return;
	}