<div class="tab-content">
    <?php echo form_open(get_uri("clients/save_contact/"), array("id" => "contact-form", "class" => "general-form dashed-row white", "role" => "form")); ?>
    <div class="card border-top-0 rounded-top-0">
        <div class=" card-header">
            <h4> <?php echo app_lang('general_info'); ?></h4>
        </div>
        <div class="card-body">
            <?php echo view("clients/contacts/contact_general_info_fields"); ?>
        </div>
        <?php if ($can_edit_clients) { ?>
            <div class="card-footer">
                <button type="submit" class="btn btn-primary"><span data-feather="check-circle" class="icon-16"></span> <?php echo app_lang('save'); ?></button>
            </div>
        <?php } ?>
    </div>
    <?php echo form_close(); ?>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        var phoneInput = initializeIntlTelInput("#contact_phone");

        $("#contact-form").appForm({
            isModal: false,
            beforeAjaxSubmit: function(data) {
                $.each(data, function(index, obj) {
                    if (obj.name === "phone" && phoneInput) {
                        data[index].value = phoneInput.getNumber();
                    }
                });
            },
            onSuccess: function(result) {
                appAlert.success(result.message, {
                    duration: 10000
                });
                setTimeout(function() {
                    window.location.href = "<?php echo get_uri("clients/contact_profile/" . $model_info->id); ?>" + "/general";
                }, 500);
            }
        });
    });
</script>