HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux bsx-1-dev 6.8.0-101-generic #101-Ubuntu SMP PREEMPT_DYNAMIC Mon Feb 9 10:15:05 UTC 2026 x86_64
User: www-data (33)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/bsx/ass/tab-side.php
<?php

add_shortcode('campaign-kpis','campaign_kpis');

function campaign_kpis() {
    $id   = get_queried_object_id();
    $kpis = getKpis($id);

    $cntr = get_field("contract",$id);
    $cntr_id = $cntr[0]->ID;
    $cass = get_field("cassandra",$id);
    $cass_id = $cass[0]->ID;
    $comp = get_field("company",$id);
    $comp_id = $comp[0]->ID;


    $ysym      = get_field("ysym", $cntr_id);
    $fx      = get_field("currency", $cntr_id);
    $stat = getStatus($id);
        
    $kpi_rows = array(
        'Entry date/time'   => $kpis->edt,
        'Entry price'       => sprintf("%8.3f %s", $kpis->eprc, $fx),
        ''=>'',
        'Last date/time'    => $kpis->cdt,
        'Last price'        => sprintf("%8.3f %s", $kpis->cprc, $fx),
        ' '=>'',
        'Exit date/time'    => ($stat=='Closed') ? $kpis->xdt  : '',
        'Exit price'        => ($stat=='Closed') ? $kpis->xprc : '',
        '  '=>'',
        'Absolute return'   => sprintf("% 7.3f%%",100 * $kpis->perf)
    );

    ob_start();
    tab_side_render($kpi_rows);
    return ob_get_clean();
}




function tab_side_render($rows) {

    ?>
    
    <style>

        .kennzahlen-container {
            display: flex !important;
            flex-wrap: wrap !important;
            gap: 10px 10px;
        }
        .kennzahl-item {
            display: flex;
            justify-content: space-between;
            padding: 8px 10px;
            font-size: 1.2rem;
            line-height: 1.3rem;
        }
        .kennzahl-label {
            text-align: left;
        }
        .kennzahl-wert {
            font-weight: bold;
            text-align: right;
            margin-right: 15px;
        }
    </style>

    
    <div class="kennzahlen-container">
        <?php foreach ($rows as $label => $wert): ?>
            <div class="kennzahl-item">
                <span class="kennzahl-label"><?php echo esc_html($label); ?></span>
                <span class="kennzahl-wert"><?php echo esc_html($wert); ?></span>
            </div>
        <?php endforeach; ?>
    </div>
    
    <?php

}