<div class="row">
    <div class="col-lg-6 col-xl-6">
        <div class="white-card plan-details eq-height">
            <h6>
                <?php
                    echo $this->package['reference'] ? $this->user->lang('Plan Details - %s', $this->package['reference']) : $this->user->lang('Plan Details');
                ?>
                <span class="float-right status <?php echo $this->package['status']['statusClassClient']; ?>">
                    <?php echo $this->package['status']['statusText']; ?>
                </span>
            </h6>
            <ul>
                <?php if ($this->package['domain'] != '') { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Domain'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['domain']; ?>
                    </span>
                </li>
                <?php } ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Amount'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->unescape($this->package['recurringAmount']); ?>
                    </span>
                </li>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Billing Cycle'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->user->lang($this->package['billingCycle']); ?>
                    </span>
                </li>
                <li>
                    <span class="card-label">
                        <?php echo $this->package['nextBillDateText']; ?>
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['nextBillDate']; ?>
                    </span>
                </li>
                <?php if ($this->showAutomaticRenewal) { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Charge Card Automatically'); ?>:
                    </span>
                    <span class="card-value">
                        <input lass="form-check-input" id="toogle-automatic-cc-charge" type="checkbox"<?php echo $this->automaticRenewalChecked;?>>
                    </span>
                </li>
                <?php } ?>
            </ul>
        </div>
    </div>
    <div class="col-lg-6 col-xl-6">
        <div class="white-card additional-details eq-height">
            <h6>
                <?php echo $this->user->lang('Additional Details'); ?>
            </h6>
            <ul>
                <?php if ($this->package['registrar'] != '') { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Registrar'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['registrar']; ?>
                    </span>
                </li>
                <?php } ?>
                <?php if ($this->package['isTransfer']) { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Transfer Id'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['transferId']; ?>
                    </span>
                </li>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Transfer Status'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['transferStatus']; ?>
                    </span>
                </li>
                <?php } ?>

                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Expiration Date'); ?>:
                    </span>
                    <span class="card-value">
                        <?php echo $this->package['expirationDate']; ?>
                    </span>
                </li>
                <?php if ($this->package['eppCode'] && $this->package['status']['statusRaw'] == 'Active') { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('EPP Code'); ?>:
                    </span>
                    <span class="card-value">
                        <?php
                            if ($this->package['eppCode'] == 'N/A') {
                                echo $this->package['eppCode'];
                            } else {
                                echo '<a href="#" class="eppCodeModal">' . $this->user->lang('View Code') . '</a>';
                            }
                        ?>
                    </span>
                </li>
                <?php } ?>

                <?php if ($this->package['registrarLock'] != '' && $this->package['status']['statusRaw'] == 'Active') { ?>
                <li>
                    <span class="card-label">
                        <?php echo $this->user->lang('Registrar Lock'); ?>
                    </span>
                    <span class="card-value">
                    <?php if ($this->package['canToggleRegLock']) { ?>
                        <input lass="form-check-input" id="toogle-registrar-lock" type="checkbox"<?php echo $this->package['regLockValue'];?>>
                    <?php } else { ?>
                        <?php echo $this->package['registrarLock']; ?>
                    <?php } ?>
                    </span>
                </li>

                <?php } ?>
            </ul>
        </div>
    </div>
    <?php if (count($this->package['customFields']) > 0 || count($this->package['addons']) > 0) { ?>
    <div class="col-lg-6 col-xl-12">
        <div class="config-options">
            <div id="config-addon-tab">
                <ul class="resp-tabs-list">
                    <?php if (count($this->package['customFields']) > 0) { ?>
                    <li>
                        <span class="tab-heading">
                            <i class="fa fa-cog" aria-hidden="true"></i>
                            <?php echo $this->user->lang('More Information'); ?>
                        </span>
                    </li>
                    <?php } ?>
                    <?php if (count($this->package['addons']) > 0) { ?>
                    <li>
                        <span class="tab-heading">
                            <i class="fa fa-puzzle-piece" aria-hidden="true"></i>
                            <?php echo $this->user->lang('Addons'); ?>
                        </span>
                    </li>
                    <?php } ?>
                </ul>

                <div class="resp-tabs-container">
                    <?php if (count($this->package['customFields']) > 0) { ?>
                    <div>
                        <ul>
                            <?php foreach ($this->package['customFields'] as $customFieldKey => $customField) { ?>
                                <li>
                                    <span class="card-label">
                                        <?php echo $customField['name']; ?>
                                    </span>
                                    <span class="card-value">
                                    <?php
                                        $customField['valuetoshow'] = $this->escape($customField['valuetoshow']);
                                        $customField['value'] = $this->escape($customField['value']);
                                        if (isset($customField['password'])) {
                                            echo $customField['valuetoshow'];
                                        } elseif ($customField['valuetoshow'] == $this->user->lang("Left Blank") && !$customField['isClientChangeable']) {
                                            echo "<span class='muted'>" . $customField['valuetoshow'] . "</span>";
                                        } elseif ($customField['isClientChangeable']) {
                                            if ($customField['type'] == TYPEPASSWORD || strlen($customField['valuetoshow']) >= 25) {
                                                echo '<a href="#" data-value="' . $customField['value'] . '" data-key="' . $customFieldKey . '" data-type="' . $customField['type'] . '" class="customFieldChange" data-name="' . $customField['name'] . '">' . $this->user->lang('View %s', $customField['name'])  . '</a>';
                                            } else {
                                                echo '<a href="#" data-value="' . $customField['value'] . '" data-key="' . $customFieldKey . '" data-type="' . $customField['type'] . '" class="customFieldChange" data-name="' . $customField['name'] . '">' . $customField['valuetoshow'] . '</a>';
                                            }
                                        } elseif ($customField['type'] == TYPEPASSWORD || strlen($customField['valuetoshow']) >= 25) {
                                            echo '<a href="#" class="customFieldModal" data-content="' . $customField['valuetoshow'] . '" data-name="' . $customField['name'] . '">' . $this->user->lang('View %s', $customField['name']) . '</a>';
                                        } else {
                                            echo $customField['valuetoshow'];
                                        }
                                    ?>
                                    </span>
                                </li>
                            <?php } ?>
                        </ul>
                    </div>
                    <?php } ?>
                    <?php if (count($this->package['addons']) > 0) { ?>
                        <div>
                            <ul>
                                <?php foreach ($this->package['addons'] as $addon) { ?>
                                    <?php if ($addon['fieldtype'] !== (string)typeHIDDEN) { ?>
                                        <li>
                                            <span class="card-label">
                                                <?php echo $addon['namelanguage']; ?>
                                            </span>
                                            <span class="card-value">
                                            <?php
                                                $addonQuantity = '';
                                                $addonQuantityPrice = $addon['optioncustomerprice'];
                                                $addonQuantitySetupPrice = $addon['optionsetupprice'];
                                                if ($addon['optioncustomerquantity'] > 1 || $addon['optioncustomerquantity'] == 0) {
                                                    $addonQuantity = $addon['optioncustomerquantity'].' x ';
                                                    $addonQuantityPrice = '@ '.$addon['optioncustomerprice'].'/'.$this->user->lang("each").' = '.$addon['optioncustomerquantityprice'];

                                                    if($addon['optionsetupprice'] !== false){
                                                        $addonQuantitySetupPrice = $addon['optionsetupprice'].'/'.$this->user->lang("each").' = '.$addon['optionsetupquantityprice'];
                                                    }
                                                }
                                                echo $addonQuantity.$addon['optionnamelanguage'].' '.$addonQuantityPrice.' / '.$addon['optioncycle'];
                                                if($addonQuantitySetupPrice !== false){
                                                    echo '<br><span style="float:right;">+ '.$addonQuantity.$addonQuantitySetupPrice.' / '.$addon['optionsetup'].'</span><br><br>';
                                                }
                                            ?>
                                            </span>
                                        </li>
                                    <?php } ?>
                                <?php } ?>
                            </ul>
                        </div>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
    <?php } ?>
</div>

<script>
    $('.eppCodeModal').on('click', function(e) {
        e.preventDefault();

        $.ajax({
            url: 'index.php?fuse=clients&controller=products&action=geteppcode',
            method: 'POST',
            data: { id: productId },
            success: function(response) {
                if (!response.success) {
                    $.dialog({
                        title: clientexec.lang('Error'),
                        content: response.message || clientexec.lang('Unable to retrieve EPP code.'),
                        columnClass: 'small',
                    });
                    return;
                }

                $.dialog({
                    title: clientexec.lang('EPP Code'),
                    content: response.epp_code || clientexec.lang('N/A'),
                    columnClass: 'xsmall',
                    containerFluid: true,
                });
            },
            error: function() {
                $.dialog({
                    title: 'Error',
                    content: clientexec.lang('An unexpected error occurred.'),
                    columnClass: 'small',
                });
            }
        });
    });
</script>