Menu
Index > Helpers

dealComplete

dealComplete($data, $options = array())

Description:
Complete - all TodoValues have been received and approved.

Options:
Not currently employed.

Example:
//
$dealComplete = $this->Deals->dealComplete($data);
//
echo 'This Deal is ' . ($dealComplete ? 'complete' : 'incomplete') . '.';

/**
 * Complete - all TodoValues have been received and approved.
 * 
 * $data	array() Deal
 * return	Boolean
 */
	public function dealComplete($data, $options = array()) {
		//
		$return		= false;
		//
		if (!$data) {
			//
			return	$return;
		}
		//
		$defaults	= array(
					'todoStats'	=> array()
					,
				);
		//
		$options	= am($defaults , $options);
		//
		if (empty($options['todoStats'])) {
			//
			$totals		= $this->TodoValue->todoValueCount($data, $options);
		} else {
			//
			$totals		= $options['todoStats'];
		}
		//
		$total		= array_sum($totals['total']);
		//
		$done		= array_sum($totals['done']);
		//
		if ($total < 1) {
			//
			return	$return;
		}
		//
		if ($total <= $done) {
			//
			return	true;
		}
		//
		return		$return;
	}