<?php
if (!$foundCA) {
    echo "<div id='certSelectionUpload' class='control-label controls certSelection'><div class='createCaBtn span'>";
    echo CHtml::link(__('NETWORK_CERTIFICATE_SETTINGS_CREATE_CA'), '#', array(
        'class' => 'btn btn-primary',
        'onClick' => 'openCaModal()',
        'data-custom-contexthelp-key' => 'CERTIFICATE_CREATE_CA_BTN_CONTEXT_HELP'
    ));
    echo "</div></div>";
} else {
    echo '<div id="certSelectionCreate" class="certSelection">';
    echo $form->passwordFieldRow($model, 'passphrase', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_PASSPHRASE',
    ));

    echo $form->textFieldRow($model, 'countryName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_COUNTRY_NAME',
    ));

    echo $form->textFieldRow($model, 'stateName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_STATE_NAME',
    ));

    echo $form->textFieldRow($model, 'cityName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_CITY_NAME',
    ));

    echo $form->textFieldRow($model, 'companyName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_COMPANY_NAME',
    ));

    echo $form->textFieldRow($model, 'orgUnitName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_ORG_UNIT_NAME',
    ));

    echo $form->textFieldRow($model, 'commonName', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_COMMON_NAME',
    ));

    echo $form->textFieldRow($model, 'eMailAddress', array(
        'data-translation-id' => 'NETWORK_CERTIFICATE_SETTINGS_EMAIL_ADDRESS',
    ));

    echo '</div>';
}
?>
<script>
    toggleSaveBtnState();

    function toggleSaveBtnState() {
        var foundCA = '<?php echo $foundCA; ?>';
        if (typeof foundCA !== "undefined" && foundCA !== '1') {
            $('#cert-grid_Modal_saveBtn').attr("disabled", true);
            $('#cert-grid_hiddenSaveBtn').attr("disabled", true);
        } else {
            $('#cert-grid_Modal_saveBtn').attr("disabled", false);
            $('#cert-grid_hiddenSaveBtn').attr("disabled", false);
        }
    }
</script>
