{config_load file="$language.conf" section="status"}

{if $cnt_distinct}
    <script language="javascript"
            src="{mh_cfg key='MH_CATALOG_SERVER'}{mh_cfg key='MH_DIR_WS_CATALOG'}{mh_cfg key='MH_ROOT_PATH'}common/js/easy-pie/jquery.easy-pie-chart.js"></script>
    <link rel="stylesheet" type="text/css" media="print, projection, screen"
          href="{mh_cfg key='MH_CATALOG_SERVER'}{mh_cfg key='MH_DIR_WS_CATALOG'}{mh_cfg key='MH_ROOT_PATH'}dashboardbeez/dashboard_status/dashboard_status.css">
{literal}
    <script type="text/javascript">

        var color_blue = '#9ac2df';
        var color_red = '#da4f49';
        var color_yellow = '#fff7a5';
        var color_orange = '#f8933c';
        var color_green = '#abd37f';

        var initPieChartDashboardStatus = function () {

            jQuery('.system_status_subscription_cnt').easyPieChart({
                barColor: function (percent) {
                    percent /= 100;

                    //{/literal}
                    usageOk = {$subscription_cnt_ok_usage};
                    usageWarning = {$subscription_cnt_warning_usage};
                    usageAlert = {$subscription_cnt_alert_usage};
                    //{literal}
                    if (percent < usageOk) {
                        // good
                        return color_green;

                    } else if (percent < usageWarning) {
                        // ok
                        return color_orange

                    } else if (percent < usageAlert) {
                        // bad
                        return color_red

                    } else {
                        return color_red

                    }
                },
                size: 50,
                trackColor: '#e0e0e0',
                scaleColor: false,
                lineCap: 'round',
                lineWidth: 5,
                animate: 500
            });
        };
    </script>
{/literal}
    <div c_lass="system_bar" st yle="display: block">
        <div class="dashboard_system_bar_container">

        {if not $is_saas}
            {if not $subscription.is_pro}
                <div class="badge_note" style="display: block; margin-top: 15px; margin-bottom: 20px; padding: 15px;">



                    <!-- HTML-only collapsible (no JS) -->
                    <details id="info"
                             onmouseover="document.getElementById('info').setAttribute('open',''); return false;"
                    >
                    <summary >
                        <div style=" float:right; text-align: right; line-height: 18px;">
                        <a href="{#text_pro_consulting_call_link#}" target="_blank" class="ceebox" rel="iframe"
                           style="font-size: 12px; color: #ffffff; font-family: inherit">{#text_pro_consulting_call#}</a><br>
                        <a href="{$subscription_link}" target="_blank" class="ceebox" rel="iframe"
                           style="font-size: 12px; color: #ffffff;; font-family: inherit">{#subscription_promo_link_subscribe#}</a>
                        </div>
                        <span style="font-size: 12px; line-height: 18px; color: #ffffff;">
                            <b>
                        {#text_community_edition#}
                            </b>
                        <div style="width: 65px; display: inline-block; margin-left: 10px;">
                    <svg viewBox="0 0 512 96" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

                        <!-- Generator: Sketch 53.2 (72643) - https://sketchapp.com -->
                        <g id="Trustpilot_ratings_5star-RGB" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                            <g fill-rule="nonzero">
                                <rect id="Rectangle-path" fill="#00B67A" x="0" y="0" width="96" height="96"></rect>
                                <rect id="Rectangle-path" fill="#00B67A" x="104" y="0" width="96" height="96"></rect>
                                <rect id="Rectangle-path" fill="#00B67A" x="208" y="0" width="96" height="96"></rect>
                                <rect id="Rectangle-path" fill="#00B67A" x="312" y="0" width="96" height="96"></rect>
                                <rect id="Rectangle-path" fill="#00B67A" x="416" y="0" width="96" height="96"></rect>
                                <path d="M48,64.7 L62.6,61 L68.7,79.8 L48,64.7 Z M81.6,40.4 L55.9,40.4 L48,16.2 L40.1,40.4 L14.4,40.4 L35.2,55.4 L27.3,79.6 L48.1,64.6 L60.9,55.4 L81.6,40.4 L81.6,40.4 L81.6,40.4 L81.6,40.4 Z" id="Shape" fill="#FFFFFF"></path>
                                <path d="M152,64.7 L166.6,61 L172.7,79.8 L152,64.7 Z M185.6,40.4 L159.9,40.4 L152,16.2 L144.1,40.4 L118.4,40.4 L139.2,55.4 L131.3,79.6 L152.1,64.6 L164.9,55.4 L185.6,40.4 L185.6,40.4 L185.6,40.4 L185.6,40.4 Z" id="Shape" fill="#FFFFFF"></path>
                                <path d="M256,64.7 L270.6,61 L276.7,79.8 L256,64.7 Z M289.6,40.4 L263.9,40.4 L256,16.2 L248.1,40.4 L222.4,40.4 L243.2,55.4 L235.3,79.6 L256.1,64.6 L268.9,55.4 L289.6,40.4 L289.6,40.4 L289.6,40.4 L289.6,40.4 Z" id="Shape" fill="#FFFFFF"></path>
                                <path d="M360,64.7 L374.6,61 L380.7,79.8 L360,64.7 Z M393.6,40.4 L367.9,40.4 L360,16.2 L352.1,40.4 L326.4,40.4 L347.2,55.4 L339.3,79.6 L360.1,64.6 L372.9,55.4 L393.6,40.4 L393.6,40.4 L393.6,40.4 L393.6,40.4 Z" id="Shape" fill="#FFFFFF"></path>
                                <path d="M464,64.7 L478.6,61 L484.7,79.8 L464,64.7 Z M497.6,40.4 L471.9,40.4 L464,16.2 L456.1,40.4 L430.4,40.4 L451.2,55.4 L443.3,79.6 L464.1,64.6 L476.9,55.4 L497.6,40.4 L497.6,40.4 L497.6,40.4 L497.6,40.4 Z" id="Shape" fill="#FFFFFF"></path>
                            </g>
                        </g>
                    </svg>
                    </div>
                            <br>
                        {#text_community_edition_sub#}
                        </span>

                    </summary>
                    <div style="padding-left: 0px; padding-right: 20px; padding-bottom: 10px; line-height: 18px;">
                        <br>
                        {#text_pro_upgrade_intro#}
                        <br>
                        <br
                            {#text_pro_body#}
                                  </div>
                    </details>

                </div>
            {/if}
        {/if}

            <div style="float:right; padding-top: 5px; padding-left: 10px;padding-bottom: 3px; width: 50%; border-left: 1px solid #c0c0c0;">

                {mh_cfg key='MAILBEEZ_SYSTEMBAR_LABEL_CUSTOMER_CNT'}: {$cnt_distinct}
            </div>


            <div _class="system-info-container" _style="float:left">


                <div class="system-info-toggle" style="float: left;">
                    {if !$show_info}
                        <div class="arrow right" style="float:left; display: inline-block"></div>
                    {/if}
                    <div style="float:left; margin-right: 10px; display: inline-block; padding-bottom: 3px;">
                        {#heading_system_status#}
                    </div>
                    <div style="float:left; display: inline-block;">
                        <div class="badge_{$status_summary|lower}" style="margin-top: -3px;">
                            {if ($status_summary == 'OK')}
                                {#system_status_ok#}
                            {elseif ($status_summary == 'WARNING')}
                                {#system_status_warning#}
                            {elseif ($status_summary == 'ERROR')}
                                {#system_status_error#}
                            {/if}
                        </div>
                    </div>
                </div>
                <div class="system-info"
                        {if $show_info}
                            style="max-height: 200px !important;"
                        {else}
                        {/if}
                >

                    <div class="sb_info_block">
                        <h1>{#system#}</h1>
                        <div class="sys_status_chart" style="width: 30%; max-width: 100px; text-align: center">
                            {if ($system.status == 'OK')}
                                <i class="fa fa-check-circle fa-5x color_success"></i>
                            {elseif ($system.status == 'INIT')}
                                <i class="fa fa-question-circle fa-5x" style="color: #c0c0c0"></i>
                            {elseif ($system.status == 'CHECK')}
                                <i class="fa fa-exclamation-circle fa-5x color_warning"></i>
                            {/if}
                        </div>
                        <div class="sys_status_chart" style="text-align: left; width: auto; max-width: 65%">


                            {if ($system.status == 'OK')}
                                {#system_ok#}
                            {elseif ($system.status == 'INIT')}
                                {#system_init#}
                            {elseif ($system.status == 'CHECK')}
                                {#system_check#}
                            {/if}
                            <br>
                            <br>
                            {if $system.status ne 'INIT'}

                                {#system_last_run#}:
                                <abbr class="timeago"
                                      title="{$system.data.last_run_date}">{$system.data.last_run_date}</abbr>
                                {if ($system.data.last_run_warning == 'LATE')}
                                    <br>
                                    <div class="badge_warning">{#system_last_run_warning#}</div>
                                {elseif ($system.data.last_run_warning == 'INCOMPLETE')}
                                    <br>
                                    <div class="badge_warning">{#system_last_run_warning_incomplete#}</div>
                                {/if}
                                <br>
                                {#system_last_sent#}:
                                <abbr class="timeago"
                                      title="{$system.data.last_sent_date}">{$system.data.last_sent_date}</abbr>
                                {if ($system.data.last_sent_warning == 'LATE')}
                                    <br>
                                    <div class="badge_warning">{#system_last_sent_warning#}</div>
                                {/if}
                            {/if}
                        </div>
                    </div>

                    {if not $is_saas}
                        <div class="sb_info_block">

                            {if $subscription.is_pro}
                                <h1>{#subscription#}: {$subscription.data.value.title}</h1>
                                <div>

                                    <div align="center"
                                         style="margin: auto;"
                                         class="sys_status dashboard_sys_status_container">
                                        <div class="sys_status_chart"
                                             style="width: 30%; max-width: 100px; padding-top: 8px;">
                                            {if ($subscription.data.status == 'ERROR')}
                                                <i class="fa fa-exclamation-triangle fa-5x color_error"></i>
                                            {else}
                                                <div class="system_status_subscription_cnt"
                                                     data-percent="{$subscription.data.value.customer_usage_perc}"
                                                     style="margin: auto">
                                                    <span>{$subscription.data.value.customer_usage_perc}</span>%
                                                </div>
                                                <div class="label">
                                                    {#customer_limit#}<br>
                                                    {$cnt_distinct} / {$subscription.data.value.max_customers}
                                                </div>
                                            {/if}


                                        </div>
                                        <div class="sys_status_chart"
                                             style="text-align: left; width: auto; max-width: 65%">
                                            {#subscription_valid_until#}
                                            <br>
                                            <abbr class="timeago"
                                                  title="{$subscription.data.value.expiration_date}">{$subscription.data.value.expiration_date}</abbr>


                                            {if ($subscription.data.status == 'OK')}

                                            {else}
                                                <br>
                                                <div class="badge_{$subscription.data.status|lower}">
                                                    {if ($subscription.data.value.message == 'WARNING_EXPIRED')}
                                                        {#subscription_expire_error#}
                                                    {elseif ($subscription.data.value.message == 'WARNING_CUSTOMER_CNT')}
                                                        {#subscription_limit_warning#}
                                                    {elseif ($subscription.data.value.message == 'ERROR_EXCEED_CUSTOMER_CNT')}
                                                        {#subscription_limit_error#}
                                                    {elseif ($subscription.data.value.message == 'WARNING_EXPIRES_SOON')}
                                                        {#subscription_expire_warning#}
                                                    {/if}
                                                </div>
                                                {if ($subscription.data.value.message == 'WARNING_EXPIRED')}
                                                    <br>
                                                    <a href="{$subscription_link}" target="_blank" class="ceebox"
                                                       _rel="iframe">
                                                        {#subscription_booknew#}
                                                    </a>
                                                {elseif ($subscription.data.value.message == 'ERROR_EXCEED_CUSTOMER_CNT' || $subscription.data.value.message == 'WARNING_CUSTOMER_CNT')}
                                                    <br>
                                                    <a href="{$subscription_link}" target="_blank" class="ceebox"
                                                       _rel="iframe">
                                                        {#subscription_upgrade#}
                                                    </a>
                                                {/if}


                                            {/if}




                                            {*
                                               <br>
                                               status {$subscription.data.status}
                                               <br>
                                               is pro {$subscription.is_pro}
                                               <br>
                                               expires {$subscription.data.value.expires_in}
                                               <br>
                                               expiration_date
                                               <br>
                                               max_customer {$subscription.data.value.max_customers}
                                            *}

                                        </div>
                                    </div>
                                </div>
                            {else}
                                <h1>{#subscription#}: {#subscription_community#}</h1>
                                <div class="sys_status_chart" style="width: 30%; max-width: 100px; text-align: center">
                                    <i class="fa fa-line-chart fa-5x color_success"></i>
                                </div>
                                <div class="sys_status_chart" style="text-align: left; width: auto; max-width: 65%">
                                    {#subscription_promo#}
                                    <br>
                                    <a href="{#subscription_promo_link_info_url#}" target="_blank">
                                        {#subscription_promo_link_info#}
                                    </a> |
                                    <a href="{$subscription_link}" target="_blank" class="ceebox" rel="iframe">
                                        {#subscription_promo_link_subscribe#}
                                    </a>
                                </div>
                            {/if}
                        </div>
                    {/if}

                    <div class="sb_info_block">

                        <h1>{#emailengine#}</h1>

                        <div class="sys_status_chart" style="width: 30%; max-width: 100px; text-align: center">
                            {if ($status_mlbz_email_active)}
                                {if ($mlbz_email_data.status == 'OK') }
                                    <i class="fa fa-check-circle fa-5x color_success"></i>
                                {elseif ($mlbz_email_data.status == 'WARNING') }
                                    <i class="fa fa-exclamation-circle fa-5x color_warning"></i>
                                {elseif ($mlbz_email_data.status == 'ERROR') }
                                    <i class="fa fa-exclamation-triangle fa-5x color_error"></i>
                                {/if}
                            {elseif ($status_n2go_active)}
                                {if ($n2go_data.status == 'OK') }
                                    <i class="fa fa-check-circle fa-5x color_success"></i>
                                {elseif ($n2go_data.status == 'WARNING') }
                                    <i class="fa fa-exclamation-circle fa-5x color_warning"></i>
                                {elseif ($n2go_data.status == 'ERROR') }
                                    <i class="fa fa-exclamation-triangle fa-5x color_error"></i>
                                {/if}
                            {else}
                                {if $email_status.status eq 'OK'}
                                    <i class="fa fa-check fa-5x" style="color: #c0c0c0"></i>
                                {elseif $email_status.status eq 'ERROR'}
                                    <i class="fa fa-exclamation-triangle fa-5x color_error"></i>
                                {/if}
                            {/if}

                        </div>
                        <div class="sys_status_chart" style="text-align: left; width: auto; max-width: 65%">

                            {if ($status_mlbz_email_active)}
                                {$email_mlbz_email_active_status}
                                {#mlbz_email#}
                                <br/>
                                <br/>
                                {if ($mlbz_email_data.status == 'OK') }
                                    <b>{#mlbz_email_ok#}</b>
                                {/if}
                                {if ($mlbz_email_data.status == 'ERROR') }
                                    <b>{#mlbz_email_error#}</b>
                                {/if}
                            {elseif ($status_n2go_active)}
                                {$email_n2go_active_status}
                                {#n2go#}
                                <br/>
                                {capture name='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_API_VERSION'}{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_API_VERSION'}{/capture}
                                {if  $smarty.capture.MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_API_VERSION eq 'v1'}
                                    <b class="color_warning">
                                        <br>
                                        {if $n2go_data.migration.status == 'not_available'}
                                            {#n2go_upgrade_hint#}
                                            <br>
                                            <a href="{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_UPGRADE_URL'}"
                                               target="_blank">{#n2go_upgrade_hint_button#}</a>
                                        {elseif $n2go_data.migration.status == 'waiting'}
                                            {#n2go_upgrade_waiting#}

                                            {if ($n2go_data.msg ne 'INTEGRATION_UPGRADE_WAITING')}
                                                <br>
                                                {#n2go_upgrade_waiting_msg#}
                                                <abbr class="timeago"
                                                      title="{$n2go_data.migration.date}">{$n2go_data.migration.date}</abbr>
                                            {/if}

                                        {elseif $n2go_data.migration.status == 'available'}
                                            <a href="{$n2go_data.migration.oauth_url}"
                                               target="_blank">{#n2go_upgrade_now#}</a>
                                        {/if}
                                    </b>
                                    <br>
                                {/if}

                                {if ($n2go_data.status == 'OK') }
                                    {*{#n2go_ok#}*}
                                    {*<br>*}
                                    <br>
                                    Credits:
                                    <b>{$n2go_data.credits}</b>
                                    <br>
                                    {if $smarty.capture.MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_API_VERSION == 'v1'}
                                        <a href="{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_LOAD_URL'}"
                                           target="_blank">{#n2go_topup_optional#}</a>
                                    {else}
                                        <a href="{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_V2_LOAD_URL'}"
                                           target="_blank">{#n2go_topup_optional#}</a>
                                    {/if}
                                    <br>
                                {else}
                                    <div class="badge_{$n2go_data.status|lower}">
                                        {if ($n2go_data.msg == 'LOW_CREDITS')}
                                            {#n2go_credits_warning#}
                                        {elseif ($n2go_data.msg == 'NO_CREDITS') }
                                            {#n2go_credits_error#}
                                        {elseif ($n2go_data.msg == 'SPF_WARNING') }
                                            {#n2go_spf_warning#}
                                        {elseif ($n2go_data.msg == 'INTEGRATION_ERROR') }
                                            {#n2go_integration_error#}
                                        {elseif ($n2go_data.msg == 'INTEGRATION_UPGRADE_WAITING') }
                                            {#n2go_upgrade_waiting_msg#}
                                            <abbr class="timeago"
                                                  title="{$n2go_data.migration.date}">{$n2go_data.migration.date}</abbr>
                                        {elseif ($n2go_data.msg == 'INTEGRATION_UPGRADE_AVAILABLE') }
                                            {#n2go_upgrade_available_msg#}
                                        {/if}
                                    </div>
                                    {if ($n2go_data.msg == 'LOW_CREDITS' || $n2go_data.msg == 'NO_CREDITS')}
                                        <br>
                                        {if $smarty.capture.MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_API_VERSION == 'v1'}
                                            <a href="{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_LOAD_URL'}"
                                               target="_blank">{#n2go_topup_optional#}</a>
                                        {else}
                                            <a href="{mh_cfg key='MAILBEEZ_CONFIG_EMAIL_ENGINE_N2G_V2_LOAD_URL'}"
                                               target="_blank">{#n2go_topup_optional#}</a>
                                        {/if}

                                    {/if}
                                    {if ($n2go_data.msg == 'SPF_WARNING' || $n2go_data.msg == 'INTEGRATION_ERROR')}
                                        <br>
                                        <a href="{$n2go_data.config_url}">{#n2go_click_to_fix#}</a>
                                    {/if}
                                    <br>
                                    <br>
                                    {#text_credits#}:
                                    <b>{$n2go_data.credits}</b>
                                {/if}

                            {else}
                                {* todo *}
                                {#emailengine_engine#}
                                {if $email_status.data.engine_shop}
                                    {if $is_saas}
                                        MailBeez Email Delivery Service
                                    {else}
                                        Shop
                                    {/if}
                                {else}
                                    Smtp-Server
                                {/if}
                                <br>
                                {if $email_status.status == 'ERROR'}
                                    <b>{#mlbz_email_error#}</b>
                                    <br>
                                {/if}

                                {if $email_status.data.error_cnt > 0}
                                    {$email_status.data.error_cnt} {#emailengine_engine_smtp_error_not_sent#}
                                    <div class="badge_error">
                                        {#emailengine_engine_smtp_error_badge#}
                                    </div>
                                    <a id="emailRepair"><i class="fa fa-wrench fa-fw"></i></a>
                                {/if}
                                {if not $is_saas}
                                    <br>
                                    {#mlbz_email_promo#}
                                    <a href="{$email_status.data.config_url}"><b>{#mlbz_email_promo_link#}</b></a>
                                {/if}
                            {/if}
                        </div>
                    </div>


                </div>


            </div>

        </div>

    </div>
{literal}
    <script type="text/javascript">
        jQuery(document).ready(function () {
            initPieChartDashboardStatus();
        });
    </script>
{/literal}
{/if}

{*

subscription: note
- no subscription


subscription: warning
- subscription limit customers
- subscription limit overdue

subscription: critical
- subscription limit customers exceeded
- subscription limit expired




system: warning
- last run > x days
- last mail > x days

system: critical
- last run > y days
- last mail > y days




newsletter2go: note
- not configured

newsletter2go: warning
- low credits

newsletter2go: critical
- no credits



*}

