Commit 00dc19e7 by Alto

Правка калькулятора

1 parent 0b3deaa5
...@@ -107,13 +107,103 @@ $(document).ready( ...@@ -107,13 +107,103 @@ $(document).ready(
{ {
if (el_wrap.length>0) if (el_wrap.length>0)
{ {
var calc_inv = parseInt(el_wrap.find('input[name="calc_inv"]').val()); var el_table = el_wrap.find('.table_result')
var calc_s = parseInt(el_wrap.find('input[name="calc_s"]').val());
var calc_rashod = parseInt(el_wrap.find('input[name="calc_rashod"]').val());
var resut_value = (calc_inv - calc_rashod)*calc_s/50; var calc_credit = parseInt(el_wrap.find('input[name="calc_credit"]').val())|0;
var calc_inv = parseInt(el_wrap.find('input[name="calc_inv"]').val())|0;
var calc_s = parseInt(el_wrap.find('input[name="calc_s"]').val())|0;
var calc_period = parseInt(el_wrap.find('input[name="calc_period"]').val())|0;
var calc_discont = parseInt(el_wrap.find('input[name="calc_discont"]').val())|0;
el_wrap.find('.calc_result_value').text((resut_value).toLocaleString('ru')); var inv_proj = 0;
var op_doh = [];
var op_ras = [];
var op_cpd = [];
var nvp = [];
var heads = [
'Год проекта',
'Инвестиции в проект, тыс. руб.',
'Операционные доходы, тыс. руб.',
'Операционные расходы, тыс. руб.',
'Читсый денежный поток, тыс. руб.',
'Ставка дисконтирования, %',
'NPV проекта',
'Индекс рентабельности инвестиций, PI'
// 'Внутренняя норма доходности, IRR'
];
var rows = [];
for (var y=0; y<heads.length; y++)
{
var cols = [];
for (var x=0; x<=calc_period; x++)
{
if (x==0)
cols.push('<th scope="row">'+heads[y]+'</th>');
else
switch (y|0)
{
case 0:
cols.push('<td align="center" width="'+(50/calc_period).toFixed(2)+'%">'+(x|0)+'</td>');
break;
case 1:
if (x==1)
{
inv_proj = (calc_inv-calc_credit)/1000;
cols.push('<td align="center">'+(inv_proj).toFixed(2)+'</td>');
}
else
cols.push('<td align="center">0</td>');
break;
case 2:
//var op_doh_cur = ((calc_credit/100)|0) + (-2+x)*0.5*((calc_credit/1000)|0);
var op_doh_cur =
0.06317*calc_s*5000*(0.02*x+1) + (calc_inv - calc_credit)/1000
/*0.8*(calc_credit-calc_inv)/1000 + 4.343*calc_s*5000*x/1000 */;
op_doh.push(op_doh_cur);
cols.push('<td align="center">'+(op_doh_cur).toFixed(2)+'</td>');
break;
case 3:
var op_ras_cur = 0.82*op_doh[x-1];
op_ras.push(op_ras_cur);
cols.push('<td align="center">'+(op_ras_cur).toFixed(2)+'</td>');
break;
case 4:
var op_cdp_cur = op_doh[x-1]-op_ras[x-1];
if (x==1)
cols.push('<td align="center">'+(inv_proj).toFixed(2)+'</td>');
else
cols.push('<td align="center">'+(op_cdp_cur).toFixed(2)+'</td>');
op_cpd.push(op_cdp_cur);
break;
case 5:
cols.push('<td align="center">'+(calc_discont|0)+'</td>');
break;
case 6:
var current_nvp = op_cpd[x-1]/Math.pow(1 - calc_discont/100, x);
if (x==calc_period)
cols.push('<td align="center">'+(current_nvp).toFixed(2)+'</td>');
else
cols.push('<td></td>');
nvp.push(current_nvp);
break;
case 7:
if (x==calc_period)
{
var current_pi = 1000*nvp[x-1]/Math.abs(calc_inv+calc_credit);
cols.push('<td align="center">'+(current_pi).toFixed(2)+'</td>');
}
else
cols.push('<td></td>');
break;
default:
cols.push('<td></td>');
break;
}
}
rows.push('<tr>'+cols.join('')+'</tr>');
}
el_table.html('<tbody>'+rows.join('')+'</tbody>');
} }
} }
......
...@@ -15,24 +15,31 @@ function fenix_calc ($atts, $content) ...@@ -15,24 +15,31 @@ function fenix_calc ($atts, $content)
'<!--Примеры эффективных-->'. '<!--Примеры эффективных-->'.
'<div id="'.$atts['id'].'" class="container fenix_calc">'. '<div id="'.$atts['id'].'" class="container fenix_calc">'.
'<div class="row">'. '<div class="row">'.
'<div class="col-12 col-md-7">'.
'<h1>'.$atts['title'].'</h1>'. '<h1>'.$atts['title'].'</h1>'.
'<div class="mb-3">'. '<div class="col-12 col-md-3">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Первоначальные инвестиции, руб</label>'. '<div class="mb-3 d-none">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Поступление кредита, руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_credit_'.$atts['id'].'" name="calc_credit" required="required" value="8329753" min="0" max="10000000" />'.
'</div>'.
'<div class="mb-3 d-none">'.
'<label for="calc_inv_'.$atts['id'].'" class="form-label mb-3">Инвестиции в проект, тыс. руб</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="0" min="0" max="10000000" />'. '<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_inv_'.$atts['id'].'" name="calc_inv" required="required" value="0" min="0" max="10000000" />'.
'</div>'. '</div>'.
'<div class="mb-3">'. '<div class="mb-3">'.
'<label for="calc_s_'.$atts['id'].'" class="form-label mb-3">Площадь помещения, м<sup>2</sup></label>'. '<label for="calc_s_'.$atts['id'].'" class="form-label mb-3">Площадь помещения, м<sup>2</sup></label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_s_'.$atts['id'].'" name="calc_s" required="required" value="20" min="10" max="10000" />'. '<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_s_'.$atts['id'].'" name="calc_s" required="required" value="250" min="150" max="400" />'.
'</div>'.
'<div class="mb-3">'.
'<label for="calc_period_'.$atts['id'].'" class="form-label mb-3">Срок, год</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_period_'.$atts['id'].'" name="calc_period" required="required" value="5" min="0" max="5" readonly="readonly" />'.
'</div>'. '</div>'.
'<div class="mb-3">'. '<div class="mb-3">'.
'<label for="calc_rashod_'.$atts['id'].'" class="form-label mb-3">Расходы, руб</label>'. '<label for="calc_discont_'.$atts['id'].'" class="form-label mb-3">Ставка дисконтирования, %</label>'.
'<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_rashod_'.$atts['id'].'" name="calc_rashod" required="required" value="0" min="0" max="10000000" />'. '<input type="number" class="form-control rounded-pill p-2 px-4" id="calc_discont_'.$atts['id'].'" name="calc_discont" required="required" value="15" min="0" max="100" />'.
'</div>'. '</div>'.
'</div>'. '</div>'.
'<div class="col-12 col-md-5">'. '<div class="col-12 col-md-9">'.
'<div class="calc_result_title text-color-3 h1">Примерный доход, руб:</div>'. '<table class="table table-striped table-hover table-bordered table_result"></table>'.
'<div class="calc_result_value text-center h3">0</div>'.
( (
has_post_thumbnail($post->ID)? has_post_thumbnail($post->ID)?
'<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="img-fluid mb-4 mb-md-0"/>': '<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="img-fluid mb-4 mb-md-0"/>':
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!