You are here

function farm_quantity_log_create in farmOS 7

Helper function for creating a farm quantity measurement log.

Parameters

string $type: The log type machine name.

string $name: Optionally specify a name for the new log.

int $timestamp: The timestamp of the log (defaults to REQUEST_TIME).

bool $done: Boolean indicating whether or not the log is done.

array $assets: An array of assets to reference in the log.

array $measurements: An array of measurements to add to the log. Example: $measurements = array( array( 'measure' => 'weight', 'value' => 100, 'units' => 'lbs', 'label' => 'Foo', ), );

string $notes: Notes to add to the log.

array $categories: An array of categories to add to the log.

Return value

\Log Returns a saved log entity.

6 calls to farm_quantity_log_create()
farm_livestock_milk_form_submit in modules/farm/farm_livestock/farm_livestock.farm_quick.milk.inc
Submit function for milk quick form.
farm_livestock_move_form_submit in modules/farm/farm_livestock/farm_livestock.farm_quick.move.inc
Submit function for movement quick form.
farm_livestock_weight_set in modules/farm/farm_livestock/farm_livestock_weight/farm_livestock_weight.module
Create a weight measurement log associated with an animal.
farm_soil_amendment_form_submit in modules/farm/farm_soil/farm_soil.farm_quick.amendment.inc
Soil amendment quick form submit.
farm_soil_compost_temperature_form_submit in modules/farm/farm_soil/farm_soil_compost/farm_soil_compost.farm_quick.inc
Submit function for compost temperature quick form.

... See full list

File

modules/farm/farm_quantity/farm_quantity_log/farm_quantity_log.module, line 376
Farm quantity log module.

Code

function farm_quantity_log_create($type, $name = '', $timestamp = REQUEST_TIME, $done = TRUE, $assets = array(), $measurements = array(), $notes = '', $categories = array()) {

  // Create a new log entity.
  $log = farm_log_create($type, $name, $timestamp, $done, $assets, $notes, $categories);

  // Add quantity measurements.
  farm_quantity_log_add_measurements($log, $measurements);

  // Return the log.
  return $log;
}