Commit 3ac377b9 authored by Kevin Stover's avatar Kevin Stover

Merge branch 'release/v2.2.49'

parents e9a77c5b 1ded91d2
......@@ -100,6 +100,7 @@ function ninja_forms_export_subs_to_csv( $sub_ids = '', $return = false ){
header("Content-Disposition: attachment; filename=".$filename);
header("Pragma: no-cache");
header("Expires: 0");
echo "\xEF\xBB\xBF"; // Byte Order Mark
echo str_putcsv($array);
die();
......
......@@ -240,6 +240,15 @@ function ninja_forms_calc_after_import_form( $form ){
}
}
}
if ( isset ( $field_rows[$y]['data']['calc_eq'] ) AND $field_rows[$y]['data']['calc_eq'] != '' ) {
$calc_eq = $field_rows[$y]['data']['calc_eq'];
foreach( $form['field'] as $inserted_field ){
$calc_eq = str_replace( 'field_'.$inserted_field['old_id'], 'field_'.$inserted_field['id'], $calc_eq );
}
$field_rows[$y]['data']['calc_eq'] = $calc_eq;
}
$field_rows[$y]['data'] = serialize( $field_rows[$y]['data'] );
$args = array(
'update_array' => array(
......@@ -251,6 +260,64 @@ function ninja_forms_calc_after_import_form( $form ){
);
ninja_forms_update_field($args);
}
if ( isset ( $form['data']['success_msg'] ) AND $form['data']['success_msg'] != '' ) {
$success_msg = $form['data']['success_msg'];
foreach( $form['field'] as $inserted_field ){
$success_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $success_msg );
}
$form['data']['success_msg'] = $success_msg;
}
if ( isset ( $form['data']['user_email_msg'] ) AND $form['data']['user_email_msg'] != '' ) {
$user_email_msg = $form['data']['user_email_msg'];
foreach( $form['field'] as $inserted_field ){
$user_email_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $user_email_msg );
}
$form['data']['user_email_msg'] = $user_email_msg;
}
if ( isset ( $form['data']['admin_email_msg'] ) AND $form['data']['admin_email_msg'] != '' ) {
$admin_email_msg = $form['data']['admin_email_msg'];
foreach( $form['field'] as $inserted_field ){
$admin_email_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $admin_email_msg );
}
$form['data']['admin_email_msg'] = $admin_email_msg;
}
if ( isset ( $form['data']['mp_confirm_msg'] ) AND $form['data']['mp_confirm_msg'] != '' ) {
$mp_confirm_msg = $form['data']['mp_confirm_msg'];
foreach( $form['field'] as $inserted_field ){
$mp_confirm_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $mp_confirm_msg );
}
$form['data']['mp_confirm_msg'] = $mp_confirm_msg;
}
if ( isset ( $form['data']['save_msg'] ) AND $form['data']['save_msg'] != '' ) {
$save_msg = $form['data']['save_msg'];
foreach( $form['field'] as $inserted_field ){
$save_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $save_msg );
}
$form['data']['save_msg'] = $save_msg;
}
if ( isset ( $form['data']['save_email_msg'] ) AND $form['data']['save_email_msg'] != '' ) {
$save_email_msg = $form['data']['save_email_msg'];
foreach( $form['field'] as $inserted_field ){
$save_email_msg = str_replace( '[ninja_forms_field id='.$inserted_field['old_id'].']', '[ninja_forms_field id='.$inserted_field['id'].']', $save_email_msg );
}
$form['data']['save_email_msg'] = $save_email_msg;
}
$args = array(
'update_array' => array(
'data' => serialize( $form['data'] ),
),
'where' => array(
'id' => $form['id'],
),
);
ninja_forms_update_form($args);
}
}
}
\ No newline at end of file
......@@ -346,6 +346,7 @@ function ninja_forms_tab_view_subs(){
add_filter('ninja_forms_field', 'ninja_forms_edit_sub_default_value', 15, 2);
add_filter('ninja_forms_field', 'ninja_forms_edit_sub_hide_fields', 99, 2);
add_filter( 'ninja_forms_display_form_form_data', 'ninja_forms_edit_sub_remove_ajax' );
remove_action('ninja_forms_display_before_fields', 'ninja_forms_display_req_items');
remove_action('ninja_forms_display_open_form_tag', 'ninja_forms_display_open_form_tag');
remove_action('ninja_forms_display_close_form_tag', 'ninja_forms_display_close_form_tag');
......@@ -430,9 +431,17 @@ function ninja_forms_tab_view_subs(){
if(isset($_POST['_ninja_forms_edit_sub']) AND $_POST['_ninja_forms_edit_sub'] == 1){
add_action( 'init', 'ninja_forms_setup_processing_class', 5 );
add_action( 'init', 'ninja_forms_set_save_sub' );
add_action( 'init', 'ninja_forms_edit_sub_remove_ajax_processing', 7 );
add_action( 'init', 'ninja_forms_edit_sub_pre_process', 999 );
}
function ninja_forms_edit_sub_remove_ajax_processing(){
global $ninja_forms_processing;
$ninja_forms_processing->update_form_setting( 'ajax', 0 );
}
function ninja_forms_edit_sub_pre_process(){
global $ninja_forms_processing;
......@@ -631,3 +640,8 @@ function ninja_forms_view_subs_default_filter( $sub_results ) {
add_filter( 'ninja_forms_view_subs_results', 'ninja_forms_view_subs_default_filter' );
add_filter( 'ninja_forms_download_all_subs_results', 'ninja_forms_view_subs_default_filter' );
function ninja_forms_edit_sub_remove_ajax( $form ){
$form['data']['ajax'] = 0;
return $form;
}
\ No newline at end of file
......@@ -12,22 +12,10 @@ function ninja_forms_field_calc_filter( $calc_data, $field_id ){
global $ninja_forms_processing;
if ( !is_object ( $ninja_forms_processing ) ) {
$field_row = ninja_forms_get_field_by_id( $field_id );
$form_id = $field_row['form_id'];
if ( $field_row['type'] == '_calc' ) {
if ( !isset ( $ninja_forms_processing ) ) {
$form_row = ninja_forms_get_form_by_field_id( $field_id );
$form_id = $form_row['id'];
$all_fields = ninja_forms_get_fields_by_form_id( $form_id );
$calc_array = array();
foreach ( $all_fields as $field ) {
if ( $field['type'] == '_calc' ) {
$calc_array[] = $field['id'];
}
}
}
//echo "Calc Filter";
// Figure out which method we are using to calculate this field.
if ( isset ( $calc_data['calc_method'] ) ) {
$calc_method = $calc_data['calc_method'];
......@@ -53,8 +41,7 @@ function ninja_forms_field_calc_filter( $calc_data, $field_id ){
$all_fields = ninja_forms_get_fields_by_form_id( $form_id );
remove_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 11, 2 );
remove_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 11 );
// Figure out if there is a sub_total and a tax field. If there are, and this is a total field set to calc_method auto, we're using an equation, not auto.
$tax = false;
$sub_total = false;
......@@ -79,6 +66,7 @@ function ninja_forms_field_calc_filter( $calc_data, $field_id ){
// Figure out how many calculation fields we have and run
$result = $calc_data['default_value'];
foreach ( $all_fields as $field ) {
if ( $field['id'] != $field_id ) {
$field_data = apply_filters( 'ninja_forms_field', $field['data'], $field['id'] );
......@@ -130,8 +118,8 @@ function ninja_forms_field_calc_filter( $calc_data, $field_id ){
break;
}
}
}
if ( $calc_method == 'eq' ) {
$eq = new eqEOS();
$result = $eq->solveIF($calc_eq);
......@@ -196,6 +184,7 @@ function ninja_forms_calc_field_loop( $field_id, $calc_eq = '', $result = '' ){
// Figure out if there is a sub_total and a tax field. If there are, and this is a total field set to calc_method auto, we're using an equation, not auto.
$tax = false;
$sub_total = false;
foreach ( $all_fields as $field ) {
$data = apply_filters( 'ninja_forms_field', $field['data'], $field['id'] );
......@@ -382,9 +371,9 @@ function ninja_forms_field_calc_value( $field_id, $field_value = '', $calc_metho
}
//$field_data = $field['data'];
remove_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 2 );
//remove_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 11, 2 );
$field_data = apply_filters( 'ninja_forms_field', $field['data'], $field_id );
add_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 11, 2 );
//add_filter( 'ninja_forms_field', 'ninja_forms_field_calc_filter', 11, 2 );
if ( isset ( $field_data['default_value'] ) ) {
$default_value = $field_data['default_value'];
......@@ -424,7 +413,7 @@ function ninja_forms_field_calc_value( $field_id, $field_value = '', $calc_metho
if ( !$field_value OR $field_value == '' ) {
$field_value = 0;
}
$calc_value = $field_value;
$calc_value = (float) preg_replace('/[^0-9.]*/','',$field_value);
}
if ( is_string( $calc_value ) AND strpos( $calc_value, "%" ) !== false ) {
......
<?php
/*
*
* Function that filters default values, replacing defined strings with the approparite values.
*
* @since 2.2.49
* @return $data
*/
function ninja_forms_default_value_filter( $data, $field_id ) {
global $current_user;
if(isset($data['default_value'])){
$default_value = $data['default_value'];
}else{
$default_value = '';
}
get_currentuserinfo();
$user_ID = $current_user->ID;
$user_firstname = $current_user->user_firstname;
$user_lastname = $current_user->user_lastname;
$user_display_name = $current_user->display_name;
$user_email = $current_user->user_email;
switch( $default_value ){
case '_user_id':
$default_value = $user_ID;
break;
case 'user_firstname':
$default_value = $user_firstname;
break;
case 'user_lastname':
$default_value = $user_lastname;
break;
case '_user_display_name':
$default_value = $user_display_name;
break;
case 'user_email':
$default_value = $user_email;
break;
}
$data['default_value'] = $default_value;
return $data;
}
add_filter( 'ninja_forms_field', 'ninja_forms_default_value_filter', 9, 2 );
\ No newline at end of file
......@@ -74,6 +74,10 @@ function ninja_forms_display_fields($form_id){
$display_style = '';
}
if ( $display_style != '' ) {
$display_style = 'style="'.$display_style.'"';
}
if ( $display_function != '' AND $show_field ) {
if ( isset( $data['label_pos'] ) ) {
$label_pos = $data['label_pos'];
......@@ -92,7 +96,7 @@ function ninja_forms_display_fields($form_id){
$field_wrap_class = apply_filters( 'ninja_forms_field_wrap_class', $field_wrap_class, $field_id );
do_action( 'ninja_forms_display_before_opening_field_wrap', $field_id, $data );
?>
<div class="<?php echo $field_wrap_class;?>" style="<?php echo $display_style;?>" id="ninja_forms_field_<?php echo $field_id;?>_div_wrap">
<div class="<?php echo $field_wrap_class;?>" <?php echo $display_style;?> id="ninja_forms_field_<?php echo $field_id;?>_div_wrap">
<?php
do_action( 'ninja_forms_display_after_opening_field_wrap', $field_id, $data );
}
......
......@@ -21,7 +21,7 @@ function ninja_forms_display_field_help( $field_id, $data ){
if($show_help){
?>
<img id="" class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>/images/question-ico.gif" title="<?php echo $help_text;?>">
<img class='ninja-forms-help-text' src="<?php echo NINJA_FORMS_URL;?>/images/question-ico.gif" title="<?php echo $help_text;?>">
<?php
}
}
......
......@@ -120,6 +120,7 @@ function ninja_forms_display_form( $form_id = '' ){
}
if($form_id != ''){ //Make sure that we have an active form_id.
$form_row = ninja_forms_get_form_by_id($form_id);
$form_row = apply_filters( 'ninja_forms_display_form_form_data', $form_row );
if( isset( $form_row['data']['ajax'] ) ){
$ajax = $form_row['data']['ajax'];
}else{
......
......@@ -24,7 +24,7 @@ function ninja_forms_display_form_title( $form_id ){
$form_title = '';
}
$title_class = '';
$title_class = 'ninja-forms-form-title';
$title_class = apply_filters( 'ninja_forms_form_title_class', $title_class, $form_id );
......
......@@ -819,6 +819,7 @@ class Ninja_Forms_Processing {
$data = $field['data'];
$field_id = $field['id'];
$user_value = $this->get_field_value( $field_id );
if ( isset ( $data['payment_total'] ) AND $data['payment_total'] == 1 ) {
$calc_method = $data['calc_method'];
if ( isset ( $data['calc'] ) ) {
......@@ -827,6 +828,7 @@ class Ninja_Forms_Processing {
$calc_eq = $data['calc_eq'];
$places = $data['calc_places'];
$total_field = $field_id;
$total_value = number_format( round( $user_value, $places ), $places );
break;
......@@ -1032,6 +1034,8 @@ class Ninja_Forms_Processing {
// Loop through the fields
foreach ( $this->data['field_data'] as $field ) {
$field_value = $this->get_field_value( $field['id'] );
// We don't want our field to be added if it's a tax field.
if ( $field['type'] != '_tax' ) {
switch ( $calc_method ) {
case 'auto':
// If this field's calc_auto_include is set to 1, then add this field's ID to the list.
......@@ -1042,6 +1046,9 @@ class Ninja_Forms_Processing {
$tmp_array[] = array( $field['id'] => $calc_value );
}
} else {
if ( $this->get_field_value( $field['id'] ) ) {
$tmp_array[] = array( $field['id'] => $this->get_field_value( $field['id'] ) );
}
// If this is a calc field, then call this same function so that we can get all the fields that contributed to that.
$tmp_array[] = $this->get_calc_fields( $field['id'] );
}
......@@ -1059,6 +1066,9 @@ class Ninja_Forms_Processing {
$tmp_array[] = array( $field['id'] => $calc_value );
}
} else {
if ( $this->get_field_value( $field['id'] ) ) {
$tmp_array[] = array( $field['id'] => $this->get_field_value( $field['id'] ) );
}
// If this is a calc field, then call this same function so that we can get all the fields that contributed to that.
$tmp_array[] = $this->get_calc_fields( $field['id'] );
}
......@@ -1076,6 +1086,9 @@ class Ninja_Forms_Processing {
$tmp_array[] = array( $field['id'] => $calc_value );
}
} else {
if ( $this->get_field_value( $field['id'] ) ) {
$tmp_array[] = array( $field['id'] => $this->get_field_value( $field['id'] ) );
}
// If this is a calc field, then call this same function so that we can get all the fields that contributed to that.
$tmp_array[] = $this->get_calc_fields( $field['id'] );
}
......@@ -1085,6 +1098,8 @@ class Ninja_Forms_Processing {
}
}
}
// Loop through our array and make sure that it's not multi-dimensional.
$calc_array = array();
foreach ( $tmp_array as $key => $field ) {
......
<?php
add_action('init', 'ninja_forms_register_fields_pre_process');
function ninja_forms_register_fields_pre_process(){
add_action('ninja_forms_pre_process', 'ninja_forms_fields_pre_process', 11 );
add_action( 'ninja_forms_pre_process', 'ninja_forms_fields_pre_process' );
}
function ninja_forms_fields_pre_process(){
......
......@@ -156,6 +156,7 @@ function ninja_forms_display_js($form_id, $local_vars = ''){
}
$form_row = ninja_forms_get_form_by_id($form_id);
$form_row = apply_filters( 'ninja_forms_display_form_form_data', $form_row );
if( isset( $form_row['data']['ajax'] ) ){
$ajax = $form_row['data']['ajax'];
}else{
......
......@@ -20,7 +20,7 @@ function ninja_forms_register_field_calc(){
'edit_custom_class' => false,
'edit_help' => false,
//'process_field' => false,
//'pre_process' => 'ninja_forms_field_calc_pre_process',
//'pre_process' => 'ninja_forms_field_calc_strip_currency_symbol',
'edit_options' => array(
array(
'type' => 'hidden',
......@@ -488,6 +488,13 @@ function ninja_forms_field_calc_pre_process(){
$calc_eq = array();
}
// Get our calculation equation if it exists.
if ( isset ( $field_data['calc_places'] ) ) {
$calc_places = $field_data['calc_places'];
} else {
$calc_places = 0;
}
$all_fields = $ninja_forms_processing->get_all_fields();
// Figure out if there is a sub_total and a tax field. If there are, and this is a total field set to calc_method auto, we're using an equation, not auto.
......@@ -533,22 +540,21 @@ function ninja_forms_field_calc_pre_process(){
case 'auto': // We are automatically totalling the fields that have a calc_auto_include set to 1.
if ( isset ( $field_data['calc_auto_include'] ) AND $field_data['calc_auto_include'] == 1 ) {
if ( $field['type'] == '_calc' ) {
$result = ninja_forms_calc_field_loop2( $field['id'], '', $result );
} else {
$calc_value = ninja_forms_calc_field_loop2( $field['id'], '', $result );
}
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
if ( $calc_value !== false ) {
$result = ninja_forms_calc_evaluate( 'add', $result, $calc_value );
}
}
}
break;
case 'fields': // We are performing a specific set of operations on a set of fields.
if ( is_array ( $calc_fields ) ) {
foreach ( $calc_fields as $c ) {
if ( $c['field'] == $field['id'] ) {
if ( $field['type'] == '_calc' ) {
$result = ninja_forms_calc_field_loop2( $field['id'], '', $result );
} else {
$calc_value = ninja_forms_calc_field_loop2( $field['id'], '', $result );
}
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
if ( $calc_value !== false ) {
$result = ninja_forms_calc_evaluate( $c['op'], $result, $calc_value );
......@@ -556,7 +562,6 @@ function ninja_forms_field_calc_pre_process(){
}
}
}
}
break;
case 'eq':
if (preg_match("/\bfield_".$field['id']."\b/i", $calc_eq ) ) {
......@@ -571,48 +576,18 @@ function ninja_forms_field_calc_pre_process(){
}
break;
}
/*
switch ( $calc_method ) {
case 'auto': // We are automatically totalling the fields that have a calc_auto_include set to 1.
if ( isset ( $data['calc_auto_include'] ) AND $data['calc_auto_include'] == 1 ) {
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
if ( $calc_value !== false ) {
$result = ninja_forms_calc_evaluate( 'add', $result, $calc_value );
}
}
break;
case 'fields': // We are performing a specific set of operations on a set of fields.
if ( is_array ( $calc_fields ) ) {
foreach ( $calc_fields as $c ) {
if ( $c['field'] == $field['id'] ) {
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
if ( $calc_value !== false ) {
$result = ninja_forms_calc_evaluate( $c['op'], $result, $calc_value );
}
}
}
}
break;
case 'eq':
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
if ( $calc_value !== false ) {
$calc_eq = preg_replace('/\bfield_'.$field['id'].'\b/', $calc_value, $calc_eq );
}
break;
}
*/
}
}
if ( $calc_method == 'eq' ) {
$eq = new eqEOS();
$result = $eq->solveIF($calc_eq);
}
if ( isset ( $field_data['calc_places'] ) ) {
$places = $field_data['calc_places'];
$result = number_format( round( $result, $places ), $places );
if ( isset ( $calc_places ) ) {
$result = number_format( round( $result, $calc_places ), $calc_places );
}
$result = str_replace( ',', '', $result );
$ninja_forms_processing->update_field_value( $field_id, $result );
}
}
......@@ -712,7 +687,7 @@ function ninja_forms_calc_field_loop2( $field_id, $calc_eq = '', $result = '' ){
case 'eq':
if (preg_match("/\bfield_".$field['id']."\b/i", $calc_eq ) ) {
if ( $field['type'] == '_calc' ) {
$calc_value = ninja_forms_calc_field_loop2( $field['id'], $calc_eq );
$calc_value = ninja_forms_calc_field_loop2( $field['id'], $calc_eq, $result );
} else {
$calc_value = ninja_forms_field_calc_value( $field['id'], $field_value, $calc_method );
}
......
......@@ -301,7 +301,7 @@ function ninja_forms_field_list_display( $field_id, $data ){
$disabled = '';
}
$label = htmlentities( $label );
$label = htmlspecialchars( $label );
$label = stripslashes( $label );
......@@ -529,8 +529,8 @@ function ninja_forms_field_list_option_output($field_id, $x, $option = '', $hidd
$hidden = 'display:none';
}
if(is_array($option)){
$label = htmlentities( $option['label'] );
$value = htmlentities( $option['value'] );
$label = htmlspecialchars( $option['label'] );
$value = htmlspecialchars( $option['value'] );
if ( isset ( $option['calc'] ) ) {
$calc = $option['calc'];
} else {
......
......@@ -155,20 +155,13 @@ jQuery(document).ready(function(jQuery) {
* Calculation Field JS
*/
// Listen to the input elements with our calculation class for focus.
jQuery('body').on( 'focus', '.ninja-forms-field-calc-listen', function(e){
jQuery(this).data( "oldValue", jQuery(this).val() );
});
// Listen to the input elements with our calculation class for focus.
jQuery('body').on( 'mousedown', '.ninja-forms-field-calc-listen', function(e){
jQuery(this).data( "oldValue", jQuery(this).val() );
});
var selects = jQuery(".ninja-forms-field-calc-listen");
// Listen to the input elements with our calculation class for focus.
jQuery('body').on( 'keydown', '.ninja-forms-field-calc-listen', function(e){
if( this.type == 'select-multiple' ) {
jQuery(this).data( "oldValue", jQuery(this).val() );
selects.each(function (i, element) {
var select = jQuery(element);
var previousValue = jQuery(this).val();
if ( this.type !== 'checkbox' ) {
jQuery(element).data("oldValue", previousValue);
}
});
......@@ -184,7 +177,9 @@ jQuery(document).ready(function(jQuery) {
// Listen to the input elements for our auto-calculation fields and change the total.
jQuery('body').on( 'change', '.ninja-forms-field-calc-listen', function(event){
if ( this == event.target ) {
// Get our calc settings.
var form_id = ninja_forms_get_form_id( this );
var field_id = jQuery(this).attr("rel");
......@@ -225,10 +220,11 @@ jQuery(document).ready(function(jQuery) {
var new_value = '';
// Set our old_value to the previous one for this field.
old_value = jQuery(this).data('oldValue');
// Check to see if we are in a list field. If we are, we can grab the calc values.
if ( jQuery('#ninja_forms_field_' + field_id + '_type' ).val() == 'list' ) {
var key = jQuery(this).val();
// See if we have any old values. If we do, compare them to our current selectino for this field and see if we need to subtract anything.
// See if we have any old values. If we do, compare them to our current selection for this field and see if we need to subtract anything.
if ( jQuery('#ninja_forms_field_' + field_id + '_list_type').val() == 'checkbox' ) {
if ( !this.checked ) {
old_value = key;
......@@ -238,7 +234,7 @@ jQuery(document).ready(function(jQuery) {
// If this is a checkbox or a radio list, then we have to check the span parent for the oldValue.
var span = jQuery(this).parent().parent().parent().parent();
old_value = jQuery(span).data('oldValue');
} else if ( jQuery(jQuery('#ninja_forms_field_' + field_id + '_list_type').val() == 'multi' ) ) {
} else if ( jQuery('#ninja_forms_field_' + field_id + '_list_type').val() == 'multi' ) {
// This is a multi-select list. The value is in an array, so we need to add all the values together.
if ( jQuery.isArray( key ) ) {
var tmp = 0;
......@@ -276,6 +272,9 @@ jQuery(document).ready(function(jQuery) {
}
}
if ( this.type !== 'checkbox' ) {
jQuery(this).data('oldValue', key);
}
if ( new_value === '' ) {
if ( typeof calc_settings.calc_value[field_id] !== 'undefined' && typeof calc_settings.calc_value[field_id][key] !== 'undefined' ) {
......@@ -283,9 +282,14 @@ jQuery(document).ready(function(jQuery) {
var new_value = calc_settings.calc_value[field_id][key];
} else {
// This field doesn't exist in the calc value object. It's either a textbox or similar element.
if ( typeof this.type === 'undefined' ) {
var new_value = this.innerHTML;
} else {
var new_value = this.value;
}
if ( typeof ninja_forms_settings.currency_symbol !== 'undefined' ) {
var new_value = this.value.replace( ninja_forms_settings.currency_symbol, "" );
new_value = new_value.replace( ninja_forms_settings.currency_symbol, "" );
new_value = new_value.replace( /,/g, "" );
}
......@@ -370,6 +374,7 @@ jQuery(document).ready(function(jQuery) {
new_value = parseFloat( new_value );
tmp = new ninja_forms_var_operator(new_op);
var calc_value = tmp.evaluate( current_value, new_value );
//console.log( current_value + ' ' + new_op + ' ' + new_value + ' = ' + calc_value );
} else {
// We don't have any calculations to do, so set calc_value to our current_value.
var calc_value = current_value;
......@@ -434,6 +439,18 @@ jQuery(document).ready(function(jQuery) {
}
}
// This field doesn't exist in the calc value object. It's either a textbox or similar element.
if ( typeof this.type === 'undefined' ) {
f_value = this.innerHTML;
} else {
f_value = this.value;
}
if ( typeof ninja_forms_settings.currency_symbol !== 'undefined' ) {
f_value = f_value.replace( ninja_forms_settings.currency_symbol, "" );
f_value = f_value.replace( /,/g, "" );
}
if ( isNaN( f_value ) || f_value == '' || !f_value || typeof f_value === 'undefined' ) {
f_value = 0;
}
......@@ -466,9 +483,9 @@ jQuery(document).ready(function(jQuery) {
}
if ( current_value !== calc_value ) {
jQuery(this).removeClass('ninja-forms-field-calc-no-old-op');
calc_value = calc_value.toFixed(calc_places);
// Set the value of our calculation field.
jQuery("#ninja_forms_field_" + calc_id).data("oldValue", current_value);
if(jQuery("#ninja_forms_field_" + calc_id).attr("type") == 'text' ){
jQuery("#ninja_forms_field_" + calc_id).val(calc_value);
}else{
......@@ -498,7 +515,7 @@ function ninja_forms_before_submit(formData, jqForm, options){
}
function ninja_forms_response(responseText, statusText, xhr, jQueryform){
//alert(responseText);
//console.log(responseText);
if( ninja_forms_settings.ajax_msg_format == 'inline' ){
var result = jQuery(jQueryform).triggerHandler('submitResponse', [ responseText ]);
if ( result !== false ) {
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
Plugin Name: Ninja Forms
Plugin URI: http://ninjaforms.com/
Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
Version: 2.2.48
Version: 2.2.49
Author: The WP Ninjas
Author URI: http://ninjaforms.com
Text Domain: ninja-forms
......@@ -51,7 +51,7 @@ global $wpdb, $wp_version;
define("NINJA_FORMS_DIR", WP_PLUGIN_DIR."/".basename( dirname( __FILE__ ) ) );
define("NINJA_FORMS_URL", plugins_url()."/".basename( dirname( __FILE__ ) ) );
define("NINJA_FORMS_VERSION", "2.2.48");
define("NINJA_FORMS_VERSION", "2.2.49");
define("NINJA_FORMS_TABLE_NAME", $wpdb->prefix . "ninja_forms");
define("NINJA_FORMS_FIELDS_TABLE_NAME", $wpdb->prefix . "ninja_forms_fields");
define("NINJA_FORMS_FAV_FIELDS_TABLE_NAME", $wpdb->prefix . "ninja_forms_fav_fields");
......@@ -109,6 +109,7 @@ require_once( NINJA_FORMS_DIR . "/includes/display/fields/inside-label-hidden.ph
require_once( NINJA_FORMS_DIR . "/includes/display/fields/field-type.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/calc-filter.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/list-term-filter.php" );
require_once( NINJA_FORMS_DIR . "/includes/display/fields/default-value-filter.php" );
/* Require Pre-Registered Tabs and their sidebars */
......
......@@ -3,7 +3,7 @@ Contributors: kstover, jameslaws, daveshine
Tags: form, forms, contact form, custom form, form builder, form creator, form manager, form creation, contact forms, custom forms, forms builder, forms creator, forms manager, forms creation, form administration,
Requires at least: 3.4
Tested up to: 3.6
Stable tag: 2.2.48
Stable tag: 2.2.49
License: GPLv2 or later
Forms created with a simple drag and drop interface. Contact forms, Email collection forms, or any other form you want on your WordPress site.
......@@ -76,16 +76,14 @@ For help and video tutorials, please visit our website: [Ninja Forms Documentati
== Upgrade Notice ==
= 2.2.47 =
= 2.2.49 =
*Bugs:*
* Fixed several bugs that could prevent calculation fields from working properly.
* Fixed several bugs that could cause calculation fields to show incorrect totals upon page load.
*Changes:*
* Added files to core to make updating extensions easier for developers.
* Duplicated or imported forms that use the [ninja_forms_field] shortcode should now have their references automatically changed after duplication/import.
* Fixed a bug that caused the Total calculation field to work incorrectly with Tax and Subtotals.
* Fixed a major bug that could cause calculation fields to not work when using the currencty input mask.
* Fixed a bug that caused special characters to appear incorrectly in List fields.