<script>
    $('body').on('click', '.btn-open-whatsapp', function()
    {
        let id = $(this).data('id');
        $('#modalSendWhatsapp .btn-whatsapp').attr('idcotizacion', id);
        $('#modalSendWhatsapp').modal('show');
    });

    $('body').on('click', '#modalSendWhatsapp .btn-whatsapp', function()
    {
        event.preventDefault();
        let id      = $(this).attr('idcotizacion');  
            phone   = $('#modalSendWhatsapp input[name="input__phone"]').val(),
            html    = '';

        $.ajax({
            url     : "<?php echo e(route('admin.send_quote')); ?>",
            method  : "POST",
            data    : {
                '_token' : "<?php echo e(csrf_token()); ?>",
                id       : id,
                phone    : phone
            },
            beforeSend   : function(){
                $('#modalSendWhatsapp .text-send').addClass('d-none');
                $('#modalSendWhatsapp .text-sending').removeClass('d-none');
            },
            success : function(r)
            {
                if(!r.status)
                {
                    $('#modalSendWhatsapp .text-send').removeClass('d-none');
                    $('#modalSendWhatsapp .text-sending').addClass('d-none');
                    toast_msg(r.msg, r.type);
                    return;
                }

                $('#modalSendWhatsapp .text-send').removeClass('d-none');
                $('#modalSendWhatsapp .text-sending').addClass('d-none');
                toast_msg(r.msg, r.type);
            },
            dataType: "json"
        });
    });

    $('body').on('click', '.btn-print', function() {
        event.preventDefault();
        let id = $(this).data('id');
        $.ajax({
            url: "<?php echo e(route('admin.print_quote')); ?>",
            method: "POST",
            data: {
                '_token': "<?php echo e(csrf_token()); ?>",
                id: id
            },
            beforeSend: function() {
                block_content('#layout-content');
            },
            success: function(r) {
                if (!r.status) {
                    close_block('#layout-content');
                    toast_msg(r.msg, r.type);
                    return;
                }
                close_block('#layout-content');
                let pdf                 =   `<?php echo e(asset('files/quotes/${r.pdf}')); ?>`;
                var iframe              = document.createElement('iframe');
                iframe.style.display    = "none";
                iframe.src              = pdf;
                document.body.appendChild(iframe);
                iframe.contentWindow.focus();
                iframe.contentWindow.print();
            },
            dataType: "json"
        });
    });

    $('body').on('click', '.btn-download', function()
    {
        event.preventDefault();
        let id              = $(this).data('id');
        base_url            = "<?php echo e(url('/')); ?>",
        url_print           = `${base_url}/download-quote/${id}`;
        window.open(url_print);
    });
</script><?php /**PATH C:\xampp\htdocs\mytems2.0\sales\resources\views/admin/quotes/js-store.blade.php ENDPATH**/ ?>