<?php
    $abacusUrl = (APPLICATION_ENV == "production") ? "https://abacus.theorchard.com/" : "https://abacus.qaorch.com/";
    $abacusUrl .= 'account/' . $this->labelResults["label_id"];
    $accountingUrl = (APPLICATION_ENV == "production") ? "https://accounting.theorchard.com/" : "https://moneyhub.qaorch.com/";
    $accountingUrl .= 'account/' . $this->labelResults["label_id"] . '/highlights/';
?>

<svg data-testid="AbacusAppIcon" class="Icon AppIcon AbacusAppIcon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="none" viewBox="0 0 48 48">
    <path fill-rule="evenodd" clip-rule="evenodd" d="M14.5556 7C10.3827 7 7 10.3827 7 14.5556V33.4444C7 37.6173 10.3827 41 14.5556 41H33.4444C37.6173 41 41 37.6173 41 33.4444V14.5556C41 10.3827 37.6173 7 33.4444 7H14.5556ZM27.7778 11.7222C26.7346 11.7222 25.8889 12.5679 25.8889 13.6111V19.2778C25.8889 20.321 26.7346 21.1667 27.7778 21.1667C28.821 21.1667 29.6667 20.321 29.6667 19.2778V13.6111C29.6667 12.5679 28.821 11.7222 27.7778 11.7222ZM12.6667 18.3333C11.6235 18.3333 10.7778 17.4877 10.7778 16.4444C10.7778 15.4012 11.6235 14.5556 12.6667 14.5556L18.3334 14.5556C19.3766 14.5556 20.2222 15.4012 20.2222 16.4444C20.2222 17.4877 19.3766 18.3333 18.3334 18.3333H12.6667ZM22.1111 33.4444C21.0679 33.4444 20.2222 32.5988 20.2222 31.5556C20.2222 30.5124 21.0679 29.6667 22.1111 29.6667H35.3334C36.3766 29.6667 37.2222 30.5124 37.2222 31.5556C37.2222 32.5988 36.3766 33.4444 35.3334 33.4444H22.1111ZM10.7778 28.7222C10.7778 27.679 11.6235 26.8333 12.6667 26.8333C13.7099 26.8333 14.5556 27.679 14.5556 28.7222V34.3889C14.5556 35.4321 13.7099 36.2778 12.6667 36.2778C11.6235 36.2778 10.7778 35.4321 10.7778 34.3889V28.7222ZM35.3334 11.7222C34.2902 11.7222 33.4445 12.5679 33.4445 13.6111V19.2778C33.4445 20.321 34.2902 21.1667 35.3334 21.1667C36.3766 21.1667 37.2222 20.321 37.2222 19.2778V13.6111C37.2222 12.5679 36.3766 11.7222 35.3334 11.7222Z" fill="url(#AbacusAppIconGradient)"></path>
    <defs>
        <linearGradient id="AbacusAppIconGradient" x1="7" y1="7" x2="34.801" y2="45.4788" gradientUnits="userSpaceOnUse">
            <stop stop-color="#f05d53"></stop>
            <stop offset="1" stop-color="#f05d53"></stop>
        </linearGradient>
    </defs>
</svg>
<a href="<?php echo $abacusUrl; ?>" style="vertical-align: 6px;font-size:13px;margin-right:15px;" target="_blank">
    <b>Abacus</b>
    <span class="ui-icon ui-icon-extlink" style="display:inline-block"></span>
</a>
<?php if ($this->canImpersonate) { ?>
<br>
<?php } ?>
<svg data-testid="MoneyhubAppIcon" class="Icon AppIcon MoneyhubAppIcon" width="20" height="20" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
    <path d="M20 17C27.1797 17 33 14.7614 33 12C33 9.23858 27.1797 7 20 7C12.8203 7 7 9.23858 7 12C7 14.7614 12.8203 17 20 17Z" fill="url(#MoneyhubAppIconGradient)"></path>
    <path d="M7.12414 17.3048C10.2413 19.4888 14.8531 20.9998 19.9989 21C18.5172 22.9726 17.5106 25.3223 17.1487 27.8794C11.9548 27.4324 7.93454 25.7899 7.14225 23.7423C7.05048 23.5128 7 23.2623 7 23V18C7 17.7556 7.04386 17.5213 7.12414 17.3048Z" fill="url(#MoneyhubAppIconGradient)"></path>
    <path d="M7.12414 28.3048C9.64516 30.0711 13.1437 31.3972 17.1117 31.84C17.4378 34.5058 18.4632 36.9555 19.9989 39C13.4754 38.9998 8.0744 37.1515 7.14224 34.7422C7.05047 34.5127 7 34.2623 7 34V29C7 28.7556 7.04386 28.5213 7.12414 28.3048Z" fill="url(#MoneyhubAppIconGradient)"></path>
    <path d="M43 30C43 36.0751 38.0751 41 32 41C25.9249 41 21 36.0751 21 30C21 23.9249 25.9249 19 32 19C38.0751 19 43 23.9249 43 30Z" fill="url(#MoneyhubAppIconGradient)"></path>
    <defs>
        <linearGradient id="MoneyhubAppIconGradient" x1="7" y1="7" x2="34.2667" y2="46.9593" gradientUnits="userSpaceOnUse">
            <stop stop-color="#f05d53"></stop>
            <stop offset="1" stop-color="#f05d53"></stop>
        </linearGradient>
    </defs>
</svg>
<a href="<?php echo $accountingUrl; ?>" style="vertical-align:6px;font-size:13px;margin-right:15px;" target="_blank">
    <b>Accounting</b>
    <span class="ui-icon ui-icon-extlink" style="display:inline-block"></span>
</a>
<?php if ($this->canImpersonate) { ?>
<br>
<?php } ?>
<div class="help-tooltip spotify-artist" style="position: absolute; display: inline-block;">
    <img src="/oa/images/icon-info.png" style="margin-left:-12px;margin-top:5px;">
        <span class="tooltiptext" style="width: 330px;margin-left:-172px;">
            You will be logged in as the Admin user for this account.
        </span>
</div>
<svg data-testid="WorkstationAppIcon" class="Icon AppIcon WorkstationAppIcon<?php echo $this->canImpersonate ? ' hide' : ''; ?>" width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M14 15C12.8954 15 12 15.8954 12 17V25C12 26.1046 12.8954 27 14 27H34C35.1046 27 36 26.1046 36 25V17C36 15.8954 35.1046 15 34 15H14Z" fill="url(#WorkstationAppIconGradient)"></path>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M36 7H12C7.58172 7 4 10.5817 4 15V27C4 31.4183 7.58172 35 12 35H22V39H16C14.8954 39 14 39.8954 14 41C14 42.1046 14.8954 43 16 43H32C33.1046 43 34 42.1046 34 41C34 39.8954 33.1046 39 32 39H26V35H36C40.4183 35 44 31.4183 44 27V15C44 10.5817 40.4183 7 36 7ZM8 15C8 12.7909 9.79086 11 12 11H36C38.2091 11 40 12.7909 40 15V27C40 29.2091 38.2091 31 36 31H12C9.79086 31 8 29.2091 8 27V15Z" fill="url(#WorkstationAppIconGradient)"></path>
    <defs>
        <linearGradient id="WorkstationAppIconGradient" x1="4" y1="7" x2="38.8136" y2="46.6736" gradientUnits="userSpaceOnUse">
            <stop stop-color="#f05d53"></stop>
            <stop offset="1" stop-color="#f05d53"></stop>
        </linearGradient>
    </defs>
</svg>
<?php if ($this->canImpersonate) { ?>
<a class="hide" href="<?php echo $this->workstationURL; ?>#sid=<?php echo $this->sessionId; ?>&username=<?php echo urlencode($this->labelResults["label_contact_login"]); ?>&vend_contact_id=<?php echo htmlspecialchars($this->labelResults["master_vend_contact_id"]); ?>" target="_blank" style="vertical-align:6px;font-size:13px;">
    <b>Workstation Login</b>
    <span class="ui-icon ui-icon-extlink" style="display:inline-block;"></span>
</a>
<?php // disable (not remove) Impersonate when target lacks auth0_user_id; default true keeps untouched callers unchanged
if (!isset($this->canImpersonateResolvable) || $this->canImpersonateResolvable) { ?>
<svg data-testid="WorkstationAppIcon" class="Icon AppIcon WorkstationAppIcon" width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M14 15C12.8954 15 12 15.8954 12 17V25C12 26.1046 12.8954 27 14 27H34C35.1046 27 36 26.1046 36 25V17C36 15.8954 35.1046 15 34 15H14Z" fill="url(#WorkstationAppIconGradient2)"></path>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M36 7H12C7.58172 7 4 10.5817 4 15V27C4 31.4183 7.58172 35 12 35H22V39H16C14.8954 39 14 39.8954 14 41C14 42.1046 14.8954 43 16 43H32C33.1046 43 34 42.1046 34 41C34 39.8954 33.1046 39 32 39H26V35H36C40.4183 35 44 31.4183 44 27V15C44 10.5817 40.4183 7 36 7ZM8 15C8 12.7909 9.79086 11 12 11H36C38.2091 11 40 12.7909 40 15V27C40 29.2091 38.2091 31 36 31H12C9.79086 31 8 29.2091 8 27V15Z" fill="url(#WorkstationAppIconGradient2)"></path>
    <defs>
        <linearGradient id="WorkstationAppIconGradient2" x1="4" y1="7" x2="38.8136" y2="46.6736" gradientUnits="userSpaceOnUse">
            <stop stop-color="#f05d53"></stop>
            <stop offset="1" stop-color="#f05d53"></stop>
        </linearGradient>
    </defs>
</svg>
<a class="applications-link-short" href="<?php echo $this->workstationURL; ?>?impersonate=alw:<?php echo htmlspecialchars($this->labelResults["master_vend_contact_id"]); ?>" target="_blank" style="vertical-align:6px;font-size:11px;">
    <b>Workstation Impersonate</b>
    <span class="ui-icon ui-icon-extlink" style="display:inline-block;width:14px;height:14px;"></span>
</a>
<?php } else { ?>
<svg data-testid="WorkstationAppIcon" class="Icon AppIcon WorkstationAppIcon" width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg" style="opacity:0.5;filter:grayscale(1);">
    <path d="M14 15C12.8954 15 12 15.8954 12 17V25C12 26.1046 12.8954 27 14 27H34C35.1046 27 36 26.1046 36 25V17C36 15.8954 35.1046 15 34 15H14Z" fill="url(#WorkstationAppIconGradient3)"></path>
    <path fill-rule="evenodd" clip-rule="evenodd" d="M36 7H12C7.58172 7 4 10.5817 4 15V27C4 31.4183 7.58172 35 12 35H22V39H16C14.8954 39 14 39.8954 14 41C14 42.1046 14.8954 43 16 43H32C33.1046 43 34 42.1046 34 41C34 39.8954 33.1046 39 32 39H26V35H36C40.4183 35 44 31.4183 44 27V15C44 10.5817 40.4183 7 36 7ZM8 15C8 12.7909 9.79086 11 12 11H36C38.2091 11 40 12.7909 40 15V27C40 29.2091 38.2091 31 36 31H12C9.79086 31 8 29.2091 8 27V15Z" fill="url(#WorkstationAppIconGradient3)"></path>
    <defs>
        <linearGradient id="WorkstationAppIconGradient3" x1="4" y1="7" x2="38.8136" y2="46.6736" gradientUnits="userSpaceOnUse">
            <stop stop-color="#999"></stop>
            <stop offset="1" stop-color="#999"></stop>
        </linearGradient>
    </defs>
</svg>
<span class="applications-link-short help-tooltip" style="position:relative;display:inline-block;vertical-align:6px;font-size:11px;color:#999;cursor:not-allowed;">
    <b>Workstation Impersonate</b>
    <span class="tooltiptext" style="width:350px;margin-left:-175px;"><?php echo !empty($this->wsImpTooltipMsg) ? $this->wsImpTooltipMsg : 'Impersonation unavailable for this contact.'; ?></span>
</span>
<?php } ?>
<?php } elseif ($this->canShowLegacyLogin) { ?>
<a href="<?php echo $this->workstationURL; ?>#sid=<?php echo $this->sessionId; ?>&username=<?php echo urlencode($this->labelResults["label_contact_login"]); ?>&vend_contact_id=<?php echo $this->labelResults["master_vend_contact_id"]; ?>" target="_blank" style="vertical-align:6px;font-size:13px;">
    <b>Workstation</b>
    <span class="ui-icon ui-icon-extlink" style="display:inline-block;"></span>
</a>
<?php } ?>
