Plugin Directory

Changeset 764318


Ignore:
Timestamp:
08/29/2013 04:49:04 PM (12 years ago)
Author:
wingdspur
Message:

added wheat harvest loss calc

Location:
farm-calculators/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • farm-calculators/trunk/farm-calculators.php

    r759708 r764318  
    77Description: Add farm calculators to your website to help users determine various farming and crop related information.
    88
    9 Version: 0.3
     9Version: 0.4
    1010Author: Bryce Johnston
    1111Author URI: http://www.wingdspur.com
     
    2828*******************************************************************************************/
    2929
    30 $fc_version = '0.3';
     30$fc_version = '0.4';
    3131$fc_dirname = plugin_basename(dirname(__FILE__));
    3232
     
    176176}
    177177
     178function farming_calc_wheat_harvest_yield_loss_shortcode() {
     179   extract( shortcode_atts( array(
     180      'class' => 'farmCalculator',
     181      ), $atts ) );
     182
     183$class = esc_attr($class);
     184
     185$code = '<div class="'.$class.'">
     186<form>
     187<div class="errors"></div>';
     188$code .='
     189  <h4>Wheat Harvest Loss</h4>
     190  <p><i>Also recommended to check standing crop for pre-harvest losses.</i></p>
     191  <p>
     192    <label for="kernals_count">Kernals Counted on Ground:</label><br />
     193    <input name="kernals_count" id="kernals_count" type="number" step="any" class="input-medium" />
     194  </p>
     195  <p>
     196    <label for="kernals_area">Area Kernals were Counted (ft<sup>2</sup>):</label><br />
     197    <input name="kernals_area" id="kernals_area" type="number" step="any" class="input-medium" />
     198  </p>
     199  <p>
     200    <button type="submit" class="btn" name="calculateWheatHarvestYieldLoss" id="calculateWheatHarvestYieldLoss">Calculate</button>
     201  </p>
     202  <p>
     203    <label>Estimated Yield Loss (bu/ac):</label><br />
     204    <input name="yield_loss" type="text" class="input-medium" readonly="readonly" />
     205  </p>
     206</form>';
     207$code .= '
     208</div>';
     209
     210   return $code;
     211}
     212
     213function farming_calc_wheat_harvest_yield_loss_bs_shortcode() {
     214   extract( shortcode_atts( array(
     215      'class' => 'farmCalculator span3',
     216      ), $atts ) );
     217
     218$class = esc_attr($class);
     219
     220$code = '<div class="'.$class.'">
     221<form>
     222<div class="errors"></div>';
     223$code .='<fieldset>
     224<legend>Wheat Harvest Loss</legend>';
     225$code .='
     226  <label for="kernals_count">Kernals Counted on Ground:</label>
     227  <input name="kernals_count" id="kernals_count" type="number" step="any" class="input-medium" />
     228  <label for="kernals_area">Area Kernals were Counted (ft<sup>2</sup>):</label>
     229  <input name="kernals_area" id="kernals_area" type="number" step="any" class="input-medium" /><br />
     230  <button type="submit" class="btn" name="calculateWheatHarvestYieldLoss" id="calculateWheatHarvestYieldLoss">Calculate</button>
     231</fieldset>';
     232$code .= '<br />
     233  <label>Estimated Yield Loss (bu/ac):</label>
     234  <input name="yield_loss" type="text" class="input-medium" readonly="readonly" />
     235</form>';
     236$code .= '
     237</div>';
     238
     239   return $code;
     240}
     241
    178242function farming_calc_sorghum_harvest_yield_loss_shortcode() {
    179243   extract( shortcode_atts( array(
     
    213277function farming_calc_sorghum_harvest_yield_loss_bs_shortcode() {
    214278   extract( shortcode_atts( array(
    215       'class' => 'farmCalculator',
     279      'class' => 'farmCalculator span3',
    216280      ), $atts ) );
    217281
     
    277341function farming_calc_soybean_harvest_yield_loss_bs_shortcode() {
    278342   extract( shortcode_atts( array(
    279       'class' => 'farmCalculator',
     343      'class' => 'farmCalculator span3',
    280344      ), $atts ) );
    281345
     
    341405function farming_calc_sunflower_harvest_yield_loss_bs_shortcode() {
    342406   extract( shortcode_atts( array(
    343       'class' => 'farmCalculator',
     407      'class' => 'farmCalculator span3',
    344408      ), $atts ) );
    345409
     
    372436add_shortcode('farming_calc_crop_population_hoop', 'farming_calc_crop_population_hoop_shortcode');
    373437add_shortcode('farming_calc_crop_population_hoop_bs', 'farming_calc_crop_population_hoop_bs_shortcode');
     438add_shortcode('farming_calc_wheat_harvest_yield_loss', 'farming_calc_wheat_harvest_yield_loss_shortcode');
     439add_shortcode('farming_calc_wheat_harvest_yield_loss_bs', 'farming_calc_wheat_harvest_yield_loss_bs_shortcode');
    374440add_shortcode('farming_calc_sorghum_harvest_yield_loss', 'farming_calc_sorghum_harvest_yield_loss_shortcode');
    375441add_shortcode('farming_calc_sorghum_harvest_yield_loss_bs', 'farming_calc_sorghum_harvest_yield_loss_bs_shortcode');
  • farm-calculators/trunk/js/calculators.js

    r759708 r764318  
    88  $("#calculateCropPopulationHoop").bind('click submit', function() {
    99    calculateCropPopulationHoop(this.form);
     10    return false;
     11  });
     12
     13  $("#calculateWheatHarvestYieldLoss").bind('click submit', function() {
     14    calculateWheatHarvestYieldLoss(this.form);
    1015    return false;
    1116  });
     
    8085  }
    8186
     87  function calculateWheatHarvestYieldLoss(form) {
     88    if (!isValid(form.kernals_count, 0, 1000)) { 
     89      return false;
     90    } else if (!isValid(form.kernals_area, 0, 1000)) { 
     91      return false;
     92    }
     93    var kernals_count = form.kernals_count.value;
     94    var kernals_area = form.kernals_area.value;
     95    var yield_loss = 0;
     96    yield_loss = kernals_count/kernals_area/20;
     97    form.yield_loss.value = roundTenth(yield_loss);
     98  }
     99
    82100  function calculateSorghumHarvestYieldLoss(form) {
    83101    if (!isValid(form.kernals_count, 0, 1000)) { 
Note: See TracChangeset for help on using the changeset viewer.