<link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/css/select2.min.css">
<link rel="stylesheet" href="<?php echo $this->request->webroot; ?>datepicker/bootstrap-datetimepicker.min.css">
<style>
    .form-group.required .control-label:before {
        color: red;
        content: "*";
        position: absolute;
        margin-left: -7px;
    }

    .cntrDiv {
        padding: 20px;
        background: #ddd;
        margin: 10px 0;
        border-radius: 5px;
    }

    @media screen and (max-width: 767px) {
        .cntrDiv {
            padding: 5px !important;
        }
    }

    #df-address .modal-dialog {
        width: 70% !important;
    }

    @media screen and (max-width: 768px) {
        #df-address .modal-dialog {
            width: calc(100% - 20px) !important;
        }
    }

    .affiliate-hide {
        display: none;
    }

    @media (min-width: 768px) {
        .modal-dialog {
            width: 600px;
            margin: 30px auto;
        }
    }

    @media only screen and (max-width: 600px) {
        .modal-dialog {
            margin: 0;
            padding: 10px;
        }
    }


</style>

<link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/rtg_popup.css?1.0.0">
<link rel="stylesheet" href="<?php echo $this->request->webroot; ?>css/youtube.css?1.0.0">
<script>
    function clearImage(imageId) {

        document.getElementById(imageId).value = null;
    }

    function resetForm() {
        document.getElementById("inputformId").reset();

    }
</script>

<input type="hidden" name="step_status" value="<?php echo $step_status; ?>">
<div class="container2">
    <div class="row1">

        <?php if ($result['text_before_video']) : ?>
            <div class="col-md-12 cntrDiv responsiveImg">
                <?php echo html_entity_decode($result['text_before_video']); ?>
            </div>
        <?php endif; ?>

        <?php if ($result['video_url']) : ?>
            <div class="col-md-12 cntrDiv">
                <div class="videoWrapper">
                    <iframe width="560" height="315" src="<?php echo $result['video_url']; ?>" frameborder="0"
                    allowfullscreen></iframe>
                    
                </div>

            </div>
        <?php endif; ?>

        <?php if (isset($result['img_after_video'])) : ?>
            <div class="col-md-12 cntrDiv">
                <img width="100%" src="<?php echo $result['img_after_video']; ?>" alt="text">
            </div>
        <?php endif; ?>

        <?php if ($result['text_after_video']) : ?>
            <div class="col-md-12 cntrDiv">
                <?php echo html_entity_decode($result['text_after_video']); ?>
            </div>
        <?php endif; ?>

        <?php if ($result['form_body']) : ?>
            <div id="formbody" class="col-md-12 ">
                <?php echo $result['form_body']; ?>
            </div>
        <?php endif; ?>

    </div>
</div>

<div id="df-address" class="modal fade" role="dialog">
    <div class="modal-dialog">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header" style="height: 44px;background:#3c8dbc;">
                <button type="button" onclick="removeViewHTML(this)" class="close client-html-close" data-dismiss="modal" style="top:30%;color: white;"><i class="fa fa-close"></i></button>
                <h4 class="modal-title" id="formModalLabel" style="line-height: 0.8; color: white;">
                    Data Furnishers
                </h4>
            </div>
            <div class="modal-body" id="top-area">
                <?php echo $this->element('data_furnishers_address'); ?>
            </div>
            <div class="modal-footer">
                <div class="row">
                    <div class="col-md-12 text-right">
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div id="client-html" class="modal fade" role="dialog">
    <div class="modal-dialog" style="width: 70%;">

        <!-- Modal content-->
        <div class="modal-content">
            <div class="modal-header" style="height: 44px;background:#3c8dbc;">
                <button type="button" onclick="removeViewHTML(this)" class="close client-html-close" data-dismiss="modal" style="top:30%;color: white;"><i class="fa fa-close"></i></button>
                <h4 class="modal-title" id="formModalLabel" style="line-height: 0.8; color: white;">
                    Credit Report HTML
                </h4>
            </div>
            <div class="modal-body" id="top-area">
                <textarea name="html_content" cols="30" rows="10" style="display:none;"></textarea>

                <div class="text-left">
                    <div id="btn-up-0" style="text-align:left;">
                        <a href="#bottom-area"><span class="glyphicon glyphicon-circle-arrow-down top-bottom-area-icon" style="font-size: 25px;display:none" title="Go To Bottom Area"></span></a>
                    </div>
                </div>

                <div class="row">
                    <div class="col-md-12 text-right">
                        <img id="save-loader" class="pull-right" style="display:none;padding-left:5px" src="<?php echo $this->Url->build('/images/ajax-loader.gif'); ?>" />
                        <button type="button" onclick="checkconsoleFunction(this, true)" class="btn btn-primary btn-orange-color rtg-save-btn rtg-save-btn-top">Save</button>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="view-html"></div>
                    </div>
                </div>
                <div class="text-left">
                    <div id="btn-up-0" style="text-align:left;margin-top:10px">
                        <a href="#top-area" id="bottom-area"><span class="glyphicon glyphicon-circle-arrow-up top-bottom-area-icon" style="font-size: 25px;display:none" title="Go To Top Area"></span></a>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <div class="row">
                    <div class="col-md-12 text-right">
                        <img id="save-loader-2" class="pull-right" style="display:none;padding-left:5px" src="<?php echo $this->Url->build('/images/ajax-loader.gif'); ?>" />
                        <button onclick="checkconsoleFunction(this, true)" type="button" class="btn btn-primary btn-orange-color rtg-save-btn">Save</button>
                    </div>
                </div>
            </div>
        </div>

    </div>
</div>

<div class="modal" id="rtg-formModal" tabindex="-1" role="dialog" aria-labelledby="formModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header" style="height: 44px;background:#3c8dbc;">
                <h4 class="modal-title" id="formModalLabel" style="line-height: 0.8; color: white;">Form Management</h4>
                <button type="button" class="close" style="margin-top: -8px;" onclick="toggleModalRTG()" aria-label="Close">
                    <span aria-hidden="true" style="color: white;"><i class="fa fa-close"></i></span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 ">
                        <div class="box-body table-responsive index-table-section" style="overflow-y:scroll; max-height:450px;">
                            <table class="display table table-bordered table-hover text-center" id="form-table">
                                <thead>
                                    <tr>
                                        <th style="color: #3c8dbc;">Id</th>
                                        <th style="color: #3c8dbc;">Personal Information</th>
                                        <th style="color: #3c8dbc;">Date of birth</th>
                                        <th style="color: #3c8dbc;">SSN</th>
                                        <th style="color: #3c8dbc;">Source</th>
                                        <th style="color: #3c8dbc;">Letter Types</th>
                                        <th style="color: #3c8dbc;">Modified On</th>
                                        <th style="color: #3c8dbc;">Date Of Next Action</th>
                                        <th style="color: #3c8dbc;">Action</th>
                                    </tr>
                                </thead>
                                <tbody>
                                </tbody>
                            </table>
                        </div>
                        <div class="modal-footer">
                            <!--                             <button id="modal-delete-btn" style="margin-top: 15px;" type="button" class="btn btn-danger pull-left" onclick="deleteAllForm()">Delete All</button>-->
                            <img style="height:25px;display:none;padding-left: 10px;margin-top: 5px;" id="delete_loading" class="rtg-loading-img pull-left" src="<?php echo $this->Url->build('/images/ajax-loader.gif'); ?>">
                            <button id="modal-btn" style="margin-top: 15px;" type="button" class="btn btn-secondary btn-success btn-orange-color" onclick="toggleModalRTG()">Close</button>
                        </div>

                    </div>
                    <!-- /.row -->
                </div>
            </div>

        </div>
    </div>
</div>

<div class="modal fade fa fa-users" id="stt-info" style="display: none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span></button>
                <h4 class="modal-title">Letter Sets</h4>
            </div>
            <div class="modal-body">

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-outline">Save changes</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<?php
$isRemovedDropDown = true;
if ($_SESSION['hasEpicVelocity'] || $_SESSION['hasVelocity']) {
    $isRemovedDropDown = false;
}
?>
<?php if ($form_id != SERTG_VELOCITY_FORM_ID) { ?>
    <link rel="stylesheet" href="<?php echo $this->request->webroot; ?>rtgv3/DataTables/datatables.min.css">

    <?php echo $this->element('rtg_all_popup'); ?>
<?php } ?>


<script src="<?php echo $this->request->webroot; ?>rtgv3/js/select2.full.min.js"></script>
<script src="<?php echo $this->request->webroot; ?>rtgv3/DataTables/datatables.min.js"></script>

<script>
    var CURRENT_DATE = '<?php echo date('m/d/Y'); ?>';
    var letter_saved_data = "";
    var letter_id = "";
    var DOB = "";
    var SSN = "";
    var CLIENT_NAME = "";
    var CLIENT_EMAIL = "";
    var DF_CREDITOR_NAME = "";
    var DF_CREDITOR_ADDRESS = "";
    var IS_CHANGE_DROPDOWN = false;
    var is_from_history = 0;
    <?php if (!empty($rtg_letter) && !empty($rtg_letter->data)) {  ?>
        letter_saved_data = JSON.parse('<?php echo addslashes($rtg_letter->data); ?>');
        letter_id = '<?php echo $rtg_letter->id; ?>'
        DOB = '<?php echo $rtg_letter->dob; ?>'
        SSN = '<?php echo $rtg_letter->ssn; ?>'
        CLIENT_NAME = letter_saved_data.client_name;
        CLIENT_EMAIL = letter_saved_data.client_email;
    <?php  }  ?>


    var FORM_ID = '<?php echo $form_id; ?>'
    var MEMBER_ID = '<?php echo $_SESSION['Auth']['User']['id']; ?>'

    var APP_SERVER_HOST_URL = '<?php echo APP_SERVER_HOST_URL; ?>'
    var SERVER_HTTP_HOST = APP_SERVER_HOST_URL

    var personal_info_selected_items = [];
    var public_info_selected_items = [];
    var inquiry_info_selected_items = [];
    var negative_info_selected_items = [];
    var late_pays_info_selected_items = [];
    var PUBLIC_RECORD_ADDRESS_LIST = [];

    var AFFILIATE_URL = '<?php echo $this->Url->build('/dashboard/getClientListByType'); ?>';
    var ENVIROMENT = '<?php echo ENVIROMENT; ?>';
    if (!$('#client-contact-id').hasClass("select2-hidden-accessible")) {
        $('#client-contact-id').select2();
    }
    var isVelocityOrRTG = true;
    var isEpicVelocity = false;
    var isRemovedDropDown = "<?php echo $is_show_address_dropdown; ?>"
    var select_url = "<?php echo $this->Url->build('/uploadhtml/getSelectedInfo/'); ?>";
    var saveIdentityID = "<?php echo $this->Url->build('/uploadhtml/identityIQSave/'); ?>";

    // for rtg_popup_dropdown.js
    var INQ_WITH_COMPANY_ASSOC = {};
    var INQ_ALL_ASSOC = {};
    var LATE_PAYS_CATEGORY = {};
    var NEGATIVE_CATEGORY = {};
    var LATE_PAYS_ALL = {};
    var ALL_BANK_ASSOC = {};
    var NEGATIVE_ALL = {};
    var MAIN_PUBLIC_RECORDS = {};
    var PUBLIC_RECORD_CATEGORY_WISE = {};
    var ALL_PERSONAL_INFO = {};
    var PERSONAL_INFO_CATEGORY_WISE = {};
    var PERSONAL_INFO_CATEGORY_WISE_ASSOC = {};
    var RTG_BANK_ASSOC = [];
    var NEGATIVE_CREDITOR_ALL = {}
    var NEGATIVE_CREDITOR_CATEGORY_WISE = {}
    var INQ_WITH_ADDRESS = {};
    var HAS_RTG_ACCESS_PKG = '<?php echo $hasRTGAccessPkg; ?>'
    var HAS_RTG_LS_FAX_ACCESS = '<?php echo $hasRtgLsFaxPkg; ?>'
    var letter_email_signature_text = '<?php echo json_encode($letter_email_signature_text); ?>';
    var CLIENT_INFO_FROM_DB = {};

    // for rtg_popup_dropdown.js

    function reportTypeChange(elem) {
        setCraReportText($(elem).val());
    }

    function disableAllActions(disable = true) {
        event.preventDefault();
        $('select[name=client_id]').prop('disabled', disable);
        $('select[name=employee_id]').prop('disabled', disable);
        $('select.credit-report-type').prop('disabled', disable);
        $('input[name=show_client_checkbox]').prop('disabled', disable);

    }

    function removeViewHTML() {
        $('.view-html').html('');

    }


    function toggleModalRTG() {
        $('body.sidebar-mini').css({
            'padding-right': '0'
        });
        $('#rtg-formModal').toggle();
    }

    $('input[name=day_value]').on('keyup, keypress', function(e) {
        if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
            // Filter non-digits from input value.
            return false;
        }
    })


    function hasDfAddressApplicable() {
        var result = false;
        var myarray = ["18", "14", "27", "31", "33", "63"];

        if ($.inArray(FORM_ID, myarray) !== -1) {
            result = true;
        }

        return result;
    }


    function hasNegativeWithPublicRecord() {
        var result = false;
        var myarray = ["33", "34", "20", "16", "35", "38", "40", "43", "44"];

        if ($.inArray(FORM_ID, myarray) !== -1) {
            result = true;
        }

        return result;
    }

    function setCraReportText(report_type_id) {
        var cr_name = "";
        if (report_type_id == 1) {
            cr_name = "Identity IQ";
        } else if (report_type_id == 3) {
            cr_name = "Smart Credit";
        }
        //alert(report_type_id);
        if (cr_name) {
            var text = cr_name + " Date " + CURRENT_DATE + " By " + cr_name;
            $('input[name=cr_data],input[name=experian_report]').val(text);
            $('#cra_report').val(text);
        }
    }

    //$('#report_file_name').change(function(){
    //    setCraReportText($(this).val());
    //})

    $('textarea[name=credit_bureau_name_address]').attr('placeholder',
        'e.g, CREDIT PLUS, 31550 WINTERPLACE PKWY SALISBURY , MD 21804');
</script>
<?php echo $this->Html->script('upload_html.js?v=2.0.2'); ?>
<?php echo $this->Html->script('creditanalysis.js?v=2.0.1'); ?>
<?php echo $this->Html->script('credit_analysis_for_SC.js'); ?>
<?php echo $this->Html->script('inq_address_dropdown.js'); ?>
<?php echo $this->Html->script('creditreport/summary.js'); ?>
<script src="<?php echo $this->request->webroot; ?>rtgv3/js/affiliate.client.js"></script>
<?php if ($form_id != SERTG_VELOCITY_FORM_ID) { ?>
    <?php echo $this->Html->script('rtg_popup_dropdown.js?1.1.9'); ?>

    <!-- for rtg letter Letterstrem & ringcentral popup -->
    <?php if ($hasRtgLsFaxPkg) { ?>
        <?php echo $this->Html->script('rtg_letter_ls_fax.js?1.0.9'); ?>
    <?php } ?>

    <!--common js and image file for rtg letters-->
    <script type="text/javascript" src="<?php echo $this->request->webroot; ?>common_script_file.js?1.0.7"></script>
    <script type="text/javascript" src="<?php echo $this->request->webroot; ?>common_image_type.js"></script>

    <?php } else {
        if (isset($_SESSION['client_id_from_dashboard']) && $_SESSION['client_id_from_dashboard'] > 0) {
            ?>
        <script>
            var selectvar = 0;
            var client_id_from_dashboard = '<?php echo $_SESSION['client_id_from_dashboard']; ?>'
            $("#client-contact-id").find('option').each(function() {
                var contact_id = $(this).val();
                if ($(this).data('id') > 0 && $(this).data('id') == client_id_from_dashboard) {
                    selectvar = contact_id
                    return false;
                }
            });

            if (selectvar > 0) {
                $("#client-contact-id").val(selectvar).trigger('change');
                //$("#client-contact-id option[data-id='" + selectvar + "']").parent('select#').trigger('change');
                $('.client-dropdown-sm-div .select2').remove();
                $("#client-contact-id").select2();
            }
        </script>
<?php

    }
} ?>

<?php echo $this->Html->script('letter_steps.js?1.0.0'); ?>
