3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Link pre grazing logs to the area animals are moving to.

This commit is contained in:
paul121 2020-06-24 15:56:57 -07:00 committed by Michael Stenta
parent 544ef28f5a
commit f0dd507f80

View file

@ -265,6 +265,20 @@ function farm_livestock_move_form_submit($form, &$form_state) {
// Create pre grazing observation log if measurements are provided.
if (!empty($pre_grazing_measurements)) {
farm_quantity_log_create('farm_observation', 'Pre grazing observation', $timestamp, TRUE, array($asset), $pre_grazing_measurements);
$pre_grazing_log = farm_quantity_log_create('farm_observation', 'Pre grazing observation', $timestamp, TRUE, array($asset), $pre_grazing_measurements);
// Link pre grazing logs to the area animals are moving to.
if (!empty($areas)) {
// Create an entity metadata wrapper for the log.
$log_wrapper = entity_metadata_wrapper('log', $pre_grazing_log);
// Add areas to log.
foreach($areas as $area) {
$log_wrapper->field_farm_area[] = $area;
}
// Save the log.
$log_wrapper->save();
}
}
}