/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@buy-addons.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author    Buy-addons    <contact@buy-addons.com>
* @copyright 2007-2020 Buy-addons
* @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/

function successful_send(){
    var html = '';
    html += '<div>';
    html +=    '<p class="alert alert-success">'+success_message+'</p>';
       html += '</div>';

    jQuery(".success_send_mail_customer").html(html);
};

jQuery(document).ready(function(){
    jQuery(".btn_customer_send").click(function(){
        var id_quote_cus = jQuery(this).attr("id_quote_customer_dbboo");
        var content_message = jQuery('.content_mess_customer').val();
        var baseurl = window.location.hostname;
        if(content_message == '')
        {    
            jQuery(".text_message_adm textarea").css("border-color", "red");
            return false;
        }else{
        
            jQuery.ajax({
                type: 'POST',//phương thức gửi
                jscrossDomain: baseurl,
                crossDomain: true,
                url: '../index.php?controller=customersendmess&fc=module&module=askforaquotemodul', // lấy link của controller mới
                data:'id_quote_cus=' + id_quote_cus + '&content_message_cus=' + content_message + '&quote_token=' + token_askaquotemodule + '&ajax=1',  // lấy dữ liệu từ id product ở trên định nghĩa
                dataType:"json",
                success: function(jsonData,textStatus,jqXHR)
                {
                    console.log(jsonData);
                    successful_send();
                    $(window).scrollTop(0);
                    myFunction();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown)
                {
                    console.log(errorThrown);
                }
            
            });
        }
    });
    function myFunction() {
		location.reload()
    }
});

