calc.php 3.43 KB
<?php 
function fenix_calc ($atts, $content)
    {
        $atts = shortcode_atts(
            array(
                'id'            => '',
                'title'         => ''
            ),
            $atts,
            'fenix_calc'
        );

        $out = '';
        $out = ''.
        '<!--Примеры эффективных-->'.
        '<div id="'.$atts['id'].'" class="container fenix_calc">'.
            '<div class="row">'.
                '<h1>'.$atts['title'].'</h1>'.
                '<div class="col-12 col-md-3">'.
                    '<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="0" min="0" max="10000000" />'.
                    '</div>'.
                    '<div class="mb-3">'.
                        '<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="10000000" min="10000000" max="250000000" />'.
                    '</div>'.
                    '<div class="mb-3">'.
                        '<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="500" min="250" max="3000" />'.
                    '</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 class="mb-3">'.
                        '<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_discont_'.$atts['id'].'" name="calc_discont" required="required" value="15" min="0" max="100" />'.
                    '</div>'.
                '</div>'.
                '<div class="col-12 col-md-9 text-center">'.
                    '<table class="table table-striped table-hover table-bordered table_result"></table>'.
                    (
                        has_post_thumbnail($post->ID)?
                            '<img src="'.get_the_post_thumbnail_url($post->ID, 'full').'" class="img-fluid mb-4 mb-md-0"/>':
                            ''
                    ).
                '</div>'.
            '</div>'.
            '<div class="row">'.
                '<div class="col-12">'.
                    '<button name="calc" type="button" class="btn btn-lg btn-style-0 rounded-pill calc_btn" role="button" id="calc_btn_'.$atts['id'].'">Рассчитать</button>'.
                '</div>'.
            '</div>'.
        '</div>';
           
        return $out;
    }
add_shortcode('fenix_calc', 'fenix_calc');