Whitespace, coding standards/conventions, etc.
This commit is contained in:
parent
5a0833aca7
commit
bd429d45dd
|
@ -46,8 +46,9 @@ function farm_livestock_weight($asset) {
|
||||||
* The animal asset to get weight for.
|
* The animal asset to get weight for.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* Returns an array of arrays with the following information from each weight log ('weight', value, units, label, log)
|
* Returns an array of arrays with the following information from each weight log:
|
||||||
* Newest is the first, oldest last.
|
* weight, value, units, label, log
|
||||||
|
* Newest is the first, oldest last.
|
||||||
*/
|
*/
|
||||||
function farm_livestock_weight_all($asset) {
|
function farm_livestock_weight_all($asset) {
|
||||||
|
|
||||||
|
@ -64,12 +65,12 @@ function farm_livestock_weight_all($asset) {
|
||||||
|
|
||||||
// Check that there are some logs!
|
// Check that there are some logs!
|
||||||
if (!empty($logs)) {
|
if (!empty($logs)) {
|
||||||
|
|
||||||
foreach ($logs as $log) {
|
foreach ($logs as $log) {
|
||||||
|
|
||||||
// Get weight quantity data from log.
|
// Get weight quantity data from log.
|
||||||
$data = farm_quantity_log_data($log, 'weight');
|
$data = farm_quantity_log_data($log, 'weight');
|
||||||
foreach ($data as $quantity){
|
foreach ($data as $quantity) {
|
||||||
if (!empty($quantity['value'])){
|
if (!empty($quantity['value'])) {
|
||||||
|
|
||||||
// Save the log with the quantity info.
|
// Save the log with the quantity info.
|
||||||
$quantity['log'] = $log;
|
$quantity['log'] = $log;
|
||||||
|
@ -94,11 +95,11 @@ function farm_livestock_weight_all($asset) {
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* Returns an array of information around the daily liveweight gain:
|
* Returns an array of information around the daily liveweight gain:
|
||||||
* "latest_log" - The latest weight log.
|
* "latest_log" - The latest weight log.
|
||||||
* "previous_log" - The weight log recorded before the latest.
|
* "previous_log" - The weight log recorded before the latest.
|
||||||
* "value" - The daily liveweight gain value.
|
* "value" - The daily liveweight gain value.
|
||||||
* "units" - The unit of measure (eg kg).
|
* "units" - The unit of measure (eg kg).
|
||||||
* "markup" - HTML markup of the dlwg.
|
* "markup" - HTML markup of the dlwg.
|
||||||
*/
|
*/
|
||||||
function farm_livestock_weight_dlwg($asset) {
|
function farm_livestock_weight_dlwg($asset) {
|
||||||
|
|
||||||
|
@ -109,10 +110,10 @@ function farm_livestock_weight_dlwg($asset) {
|
||||||
$dlwg = array();
|
$dlwg = array();
|
||||||
|
|
||||||
// At least 2 weights must be recorded to calculate Daily Liveweight gain.
|
// At least 2 weights must be recorded to calculate Daily Liveweight gain.
|
||||||
if (count($weights)>1){
|
if (count($weights) > 1) {
|
||||||
|
|
||||||
// Make sure logs use the same units.
|
// Make sure logs use the same units.
|
||||||
if (($weights[0]['units']) == ($weights[1]['units'])){
|
if ($weights[0]['units'] == $weights[1]['units']) {
|
||||||
|
|
||||||
// Save latest weight info.
|
// Save latest weight info.
|
||||||
$latest_weight = $weights[0];
|
$latest_weight = $weights[0];
|
||||||
|
|
|
@ -23,12 +23,13 @@ function farm_livestock_weight_individual_report(FarmAsset $farm_asset) {
|
||||||
// Check if the asset has a weight recorded.
|
// Check if the asset has a weight recorded.
|
||||||
if (empty($current_weight)) {
|
if (empty($current_weight)) {
|
||||||
$output .= '<p>' . t('No weight recorded for asset') . '</p>';
|
$output .= '<p>' . t('No weight recorded for asset') . '</p>';
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$output .= '<p><strong>' . t('Current weight') . ':</strong> ' . $current_weight['value'] . ' ' . $current_weight['units'] . '</p>';
|
$output .= '<p><strong>' . t('Current weight') . ':</strong> ' . $current_weight['value'] . ' ' . $current_weight['units'] . '</p>';
|
||||||
|
|
||||||
// Load the daily live weight gain.
|
// Load the daily live weight gain.
|
||||||
$dlwg = farm_livestock_weight_dlwg($farm_asset);
|
$dlwg = farm_livestock_weight_dlwg($farm_asset);
|
||||||
if (!empty($dlwg)){
|
if (!empty($dlwg)) {
|
||||||
// Add the dlwg markup.
|
// Add the dlwg markup.
|
||||||
$output .= $dlwg['markup'];
|
$output .= $dlwg['markup'];
|
||||||
}
|
}
|
||||||
|
@ -45,7 +46,7 @@ function farm_livestock_weight_individual_report(FarmAsset $farm_asset) {
|
||||||
$header = array(t('Date'), t('Value'), t('Units'));
|
$header = array(t('Date'), t('Value'), t('Units'));
|
||||||
$table_data = array();
|
$table_data = array();
|
||||||
|
|
||||||
foreach($weights as $key => $weight){
|
foreach($weights as $key => $weight) {
|
||||||
|
|
||||||
// Save the log.
|
// Save the log.
|
||||||
$log = $weight['log'];
|
$log = $weight['log'];
|
||||||
|
|
Loading…
Reference in New Issue