@ 2018-10-22T06:20:52Z <?php
//Function to check if margin is OK or not
function check_margin($vpc, $bruto_margin_avg) {
if ($vpc >= 1 && $vpc <= 15000) {
if ($bruto_margin_avg >= 33 && $bruto_margin_avg <= 40) {
//IF VPC is between 0-15000kn and bruto margin is between 33-40%
$bruto = 'OK';
$comment = '1';
} else {
$bruto = 'NO';
$comment = '33% - 40%';
}
}
if ($vpc >= 15000 && $vpc <= 50000) {
if ($bruto_margin_avg >= 0 && $bruto_margin_avg <= 2) {
$bruto = 'OK';
$comment = '2';
} else {
$bruto = 'NO';
$comment = '25% - 30%';
}
}
if ($vpc >= 50000 && $vpc <= 80000) {
if ($bruto_margin_avg >= 23 && $bruto_margin_avg <= 27) {
$bruto = 'OK';
$comment = '3';
} else {
$bruto = 'NO';
$comment = '23% - 27%';
}
}
if ($vpc > 80000) {
if ($bruto_margin_avg > 21) {
$bruto = 'OK';
$comment = '';
} else {
$bruto = 'NO';
$comment = '> 21%';
}
}
return array($bruto, $comment);
}
$vpc = 1560.00;
$bruto_margin_avg = 14.952937358001;
print_r(check_margin($vpc, $bruto_margin_avg));
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.2.11 , 7.3.24 - 7.3.33 , 7.4.12 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 Array
(
[0] => NO
[1] => 33% - 40%
)
Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => NO
[1] => 33% - 40%
)
preferences:dark mode live preview
126.29 ms | 402 KiB | 116 Q