You are here

function farm_livestock_weight_action in farmOS 7

Action function for farm_livestock_weight_action.

Creates a new weight observation log for the specified assets.

Parameters

array $assets: An array of asset entities.

array $context: Array with parameters for this action.

File

modules/farm/farm_livestock/farm_livestock_weight/farm_livestock_weight.module, line 1125
Farm livestock weight module.

Code

function farm_livestock_weight_action(array $assets, $context = array()) {

  // If we're missing assets, weight, units, or a timestamp, bail.
  if (empty($assets) || empty($context['weight']) || empty($context['units']) || empty($context['timestamp'])) {
    drupal_set_message(t('Could not set weights because required information was missing.'), 'error');
    return;
  }

  // Set the animal weights.
  farm_livestock_weight_set($assets, $context['weight'], $context['units'], $context['timestamp']);
}