-
Notifications
You must be signed in to change notification settings - Fork 0
/
bmibmr_saved.php
163 lines (143 loc) · 7.41 KB
/
bmibmr_saved.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
require( '../../../wp-load.php' );
$savedRows = get_saved_bmibmr($_REQUEST["clientid"]);
?>
<div class="row">
<?php if( !is_user_logged_in()) { ?>
<div class="notauser"></div>
<?php } ?>
<?php if( is_user_logged_in()): ?>
<div data-printCSS="<?php echo plugins_url( 'printcss.css' , __FILE__ ); ?>" id="bmiloggedin"></div>
<hr>
<!--<h3>Your previously saved data will be (is) listed here:</h3>
<a href="#" onClick="print_me()" >Print the list</a><br><br> -->
<div id="savedBMI" class="savedBMI" data-getBDataURL="<?php echo plugins_url( 'bmibmr_get.php' , __FILE__ ); ?>" data-userid="<?php echo get_current_user_id(); ?>">
<?php
foreach ($savedRows as $row) {
$fromData_arr = json_decode($row->formdata, true);
//echo '--++ '.$fromData_arr['bmibmr'];
$calc_choice = '';
if ( isset($fromData_arr['bmibmr']) && $fromData_arr['bmibmr'] == 'bmr') {
////////////////////weight convert
if ($fromData_arr['uVal'] == 'kg') {
$bmr_weight = $fromData_arr['weight'];
}
else {
$bmr_weight = $fromData_arr['weight']/(2.2);
}
//////////////////// Male/female Coefficient
if ($fromData_arr['sexoption'] == 'M') { //if man
$coefficient_mf = 1*$bmr_weight*24;
//Lean factor multiplier
if (isset($fromData_arr['bodyfat'])) {
$bodyfat = $fromData_arr['bodyfat'];
switch($bodyfat) {
case ($bodyfat>=10 && $bodyfat<=14):
$multiplier_factor = 1;
break;
case ($bodyfat>=15 && $bodyfat<=20):
$multiplier_factor = 0.95;
break;
case ($bodyfat>=21 && $bodyfat<=28):
$multiplier_factor = 0.90;
break;
case ($bodyfat>28):
$multiplier_factor = 0.90;
break;
}
}
else {
$multiplier_factor = 1;
}
}
if ($fromData_arr['sexoption'] == 'F') { //if woman
$coefficient_mf = 0.9*$bmr_weight*24;
//Lean factor multiplier
if (isset($fromData_arr['bodyfat'])) {
$bodyfat = $fromData_arr['bodyfat'];
switch($bodyfat) {
case ($bodyfat>=14 && $bodyfat<=18):
$multiplier_factor = 1;
break;
case ($bodyfat>=19 && $bodyfat<=28):
$multiplier_factor = 0.95;
break;
case ($bodyfat>=29 && $bodyfat<=38):
$multiplier_factor = 0.90;
break;
case ($bodyfat>38):
$multiplier_factor = 0.85;
break;
}
}
else {
$multiplier_factor = 1;
}
}
$BMR = round($coefficient_mf*$multiplier_factor,2);
$daily_burn = round($BMR*$fromData_arr['adalLevel'],2);
//round(1.95583, 2);
$calc_choice = '<strong>BMR : '.$BMR.', </strong> Requisição calórica diária estimadas : <strong>'.$daily_burn.'</strong><hr>';
}
else {
$calc_choice = '<strong>Somente IMC</strong><hr>';
}
//$bmi = ($fromData_arr['weight']*10000)/(pow($fromData_arr['height'],2));
if ($fromData_arr['uVal'] == 'kg') {
$bmiR = ($fromData_arr['weight']*10000)/(pow($fromData_arr['height'],2));
$bmi = round($bmiR,2);
$weight_lbs = round(($fromData_arr['weight']*2.2),2);
$height_in = round(($fromData_arr['height']*0.393700787),2);
$weight_str = $fromData_arr['weight'].' kg ( or '.$weight_lbs.' lbs)';
$height_str = $fromData_arr['height'].' cm ( or '.$height_in.' in)';
}
else {
$bmiR = (($fromData_arr['weight']/(pow($fromData_arr['height'],2)))*703);
$bmi = round($bmiR,2);
$weight_kg = round(($fromData_arr['weight']/2.2),2);
$height_cm = round(($fromData_arr['height']*2.54),2);
$weight_str = $fromData_arr['weight'].' lbs or ('.$weight_kg.' kg)';
$height_str = $fromData_arr['height'].' in or ('.$height_cm.' cm)';
}
//Body fat percentage based on entered data
//(1.20 x BMI) + (0.23 x Age) - (10.8 x gender) - 5.4
//If you are a male, your gender number is 1. If you are a female, your gender number is 0.
if ($fromData_arr['calculateauto']) {
if ($fromData_arr['sexoption'] == "M") {
//$bodyfatP = (1.20 * $bmi) + (0.23 * $fromData_arr['age']) - (10.8 * 1) - 5.4;
$gender_num = 1;
}
if ($fromData_arr['sexoption'] == "F") {
$gender_num = 0;
}
$bodyfatP = (1.20 * $bmi) + (0.23 * $fromData_arr['age']) - (10.8 * $gender_num) - 5.4;
//echo '<h4 style="color:red;">bodyfat %; '.$bodyfatP.'</h4>';
}
else {
$bodyfatP ='';
}
?>
<div class="col-md-6">
<div class="alert alert-warning " role="alert">
<div class="uListbmibmr">
<ul>
<li>
<?php
echo $calc_choice;
?>
</li>
<li>Salvo em: <span><?php echo date("F j, Y, g:i a", strtotime($row->timeof)); ?></span></li>
<li>Peso: <span><?php echo $weight_str; ?></span></li>
<li>Altura: <span><?php echo $height_str; ?></span></li>
<li>IMC: <span><?php echo $bmi; ?></span></li>
<li>Gordura corporal %: <span><?php echo $bodyfatP; ?></span></li>
<li>Nota: <span><?php echo $fromData_arr['descriptionB']; ?></span></li>
</ul>
</div>
</div> </div>
<?php
}
?>
</div>
<?php endif; ?>
</div>