<commit_before>{% extends 'Retailer/base.html.twig' %}

{% block title %}Adicionar Cotação{% endblock %}
{% block description %}{% endblock %}
{% block menu_pricelist %} active {% endblock %}

{% block page_plugins %}
    <link href="{{ asset('assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css') }}" rel="stylesheet" type="text/css" />

{% endblock %}

{% block page %}
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <style>
        .ProgressBar {
            margin: 0 auto;
            /*  padding: 2em 0 3em;*/
            list-style: none;
            position: relative;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-pack: justify;
            -ms-flex-pack: justify;
            justify-content: space-between;
            width: auto !important;
        }

        .ProgressBar-step {
            text-align: center;
            position: relative;
            width: 100%;
        }
        .ProgressBar-step:before, .ProgressBar-step:after {
            content: "";
            height: 0.2em;
            background-color: #40AE40;;
            position: absolute;
            z-index: 1;
            width: 100%;
            left: -50%;
            top: 50%;
            -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;

        }
        .ProgressBar-step:first-child:before, .ProgressBar-step:first-child:after {
            display: none;
        }
        .ProgressBar-step:after {
            background-color: #40AE40;
            border:1px solid #40AE40;
            width: 0;
        }
        .ProgressBar-step.is-complete + .ProgressBar-step.is-current:after, .ProgressBar-step.is-complete + .ProgressBar-step.is-complete:after {
            width: 100%;
        }

        .ProgressBar-icon {
            width: 2.0em;
            height: 2.0em;
            background-color: #319431;
            fill: #319431;
            border-radius: 50%;
            padding: 0.5em;
            max-width: 100%;
            z-index: 10;
            position: relative;
            margin-top: 4px;
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;
            border:2px solid #40AE40
        }
        .is-current .ProgressBar-icon {
            fill: yellow;
            background-color: yellow;
        }
        .is-complete .ProgressBar-icon {
            fill: #fff;
            background-color: #40AE40;
        }

        .ProgressBar-stepLabel {
            display: block;
            text-transform: uppercase;
            color: #9F9FA3;
            position: absolute;
            padding-top: 0.5em;
            width: 100%;
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;
        }
        .is-current > .ProgressBar-stepLabel, .is-complete > .ProgressBar-stepLabel {
            color: #00637C;
        }


        /*
        Float label styles
         */
        label:hover {
            cursor: text;
        }

        @media (max-width: 500px) {
            .contact-form {
                margin: 0 0 100px;
                width: 100%;
            }
        }
        .contact-form .email, .contact-form .message, .contact-form .text {
            position: relative;
        }
        .contact-form .email input:focus, .contact-form .email textarea:focus, .contact-form .message input:focus, .contact-form .message textarea:focus, .contact-form .text input:focus, .contact-form .text textarea:focus {
            background: #f4f5f6;
        }
        .contact-form .email label, .contact-form .message label, .contact-form .text label {
            color: #40AE40;
            left: 23px;
            position: absolute;
            top: 13px;
            -moz-transition: all, 150ms;
            -o-transition: all, 150ms;
            -webkit-transition: all, 150ms;
            transition: all, 150ms;
        }
        .contact-form .email.typing label, .contact-form .message.typing label, .contact-form .text.typing label {
            color: #40ae40;
            font-size: 10px;
            top: 2px;
        }

        .text input, .text select {
            margin: 0 auto;
            height: 44px;
            padding-top: 14px;
            width: 95%;
            border: 1px solid #40AE40
        }
        .text input:focus, .text select:focus{
            border: 1px solid #40AE40;
        }

        .contact-form .email {
            border-left: 1px #e6e6e6 solid;
            float: right;
        }
        @media (max-width: 500px) {
            .contact-form .email {
                border-left: none;
                border-top: 1px #e6e6e6 solid;
            }
        }
        .contact-form .message {
            border-bottom: 1px #e6e6e6 solid;
            border-top: 1px #e6e6e6 solid;
            clear: both;
        }
        .contact-form .message textarea {
            height: 200px;
            padding: 23px;
        }
        .contact-form .text {
            float: none;
        }
        .navbar-inner {
            background: #319431;
            width: 100%;
        }

        #rootwizard{
            background: #fff;
        }

        .wizard-container{
            padding: 12px 20px 15px;
            border-top-width: 1px;
        }

        .mt-checkbox.mt-checkbox-outline:hover>input:not([disabled]):checked ~ span, .mt-checkbox.mt-checkbox-outline>input:checked ~ span {

            background: #319431 !important;
            border-radius: 2px;
            border: 1px solid #319431;

        }

        .mt-checkbox.mt-checkbox-outline>span {
            border: 1px solid #d9d9d9;
            background: 0;
            border-radius: 2px;
            cursor: pointer;
        }
        .mt-checkbox>span:after {
            left: 6px;
            top: 2px;
            width: 5px;
            height: 10px;
            border: solid #fff;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
        }

        .error {
            border: 1px solid red !important;
        }

        .valid {
            border: 1px solid #40AE40 !important;
        }

        .nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus {
            color: transparent;
            background-color: transparent;
        }

        .nav>li>a:hover, .nav>li>a:focus {
            text-decoration: none;
            background-color: transparent;
        }
        .disabled-click {
            pointer-events: none;
            cursor: default;
        }
        td {
            text-align: center;
            vertical-align: middle;
        }
        th {
            text-align: center;
            vertical-align: middle;
        }
        .dataTables_filter{

            padding-right: 40px;

        }
        .datatable-plus-button{
            padding-top: 5px;
            top: 14px;
            padding-bottom: 5px;
            padding-right: 9px;
            background: #40AE40;
        }

        .datatable-plus-button::before {
            font-family: fontAwesome;
            content: "\f067\00a0";
            color: white;
            background-color: transparent;
        }

        .text-area{
            width: 95%;
            border: 1px solid #40AE40;
            padding-top: 14px;
            resize: vertical;
            margin-left: 2.5%;
        }

        .text select {
            margin: 0 auto;
            height: 44px;
            padding-top: 14px;
            width: 95%;
            border: 1px solid #40AE40;
        }
        .text select:focus{
            border: 1px solid #40AE40;
        }
        .modal .modal-header{
            background-color: #40AE40;
        }
        .modal-title{
            color: #FFFFFF;
        }

        .ui-autocomplete {
            z-index: 100000;
        }
    </style>

    <div class="page-wrapper-row full-height">
        <div class="page-wrapper-middle">
            <!-- BEGIN CONTAINER -->
            <div class="page-container">
                <!-- BEGIN CONTENT -->
                <div class="page-content-wrapper">
                    <!-- BEGIN CONTENT BODY -->
                    <!-- BEGIN PAGE HEAD-->
                    <div class="page-head">
                        <div class="container">
                            <!-- BEGIN PAGE TITLE -->
                            <div class="page-title">
                                <h1>Cotação
                                    <small>Complete os passos abaixo para criar a sua cotação</small>
                                </h1>
                            </div>
                            <!-- END PAGE TITLE -->
                        </div>
                    </div>
                    <!-- END PAGE HEAD-->
                    <!-- BEGIN PAGE CONTENT BODY -->
                    <div class="page-content">
                        <div class="container">
                            {% include '_partial/flashMessages.html.twig' %}
                            <!-- BEGIN PAGE BREADCRUMBS -->
                            <ul class="page-breadcrumb breadcrumb">
                                <li>
                                    <a href="{{ path('dashboard') }}">Painel Inicial</a>
                                    <i class="fa fa-circle"></i>
                                </li>
                                <li>
                                    <a href="{{ path('cotacoes') }}">Cotações</a>
                                    <i class="fa fa-circle"></i>
                                </li>
                                <li>
                                    <span>Criar Cotação</span>
                                </li>
                            </ul>
                            <!-- END PAGE BREADCRUMBS -->
                            <!-- BEGIN PAGE CONTENT INNER -->
                            <div class="page-content-inner">
                                {{ include('Retailer/pricelist/quoteWizzard.html.twig') }}
                            </div>
                            <!-- END PAGE CONTENT INNER -->
                        </div>
                    </div>
                    <!-- END PAGE CONTENT BODY -->
                    <!-- END CONTENT BODY -->
                </div>
                <!-- END CONTENT -->
            </div>
            <!-- END CONTAINER -->
        </div>
    </div>

    <svg style="display:none" xmlns="http://www.w3.org/2000/svg">
        <symbol id="checkmark-bold" viewBox="0 0 24 24">
            <path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/>
        </symbol>
    </svg>
{% endblock %}

{% block script %}
    <script src="{{ asset('assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.pt-BR.js') }}" type="text/javascript" charset="UTF-8"></script>
    <script src="{{ asset('assets/global/plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/scripts/datatable.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/datatables/datatables.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/jquery-validation/js/jquery.validate.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/jquery-validation/js/localization/messages_pt_BR.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/pages/scripts/jquery.mask.min.js') }}" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    <script>
        var supplierTable = $('#supplier-datatable');
        var listingTable = $('#listing-datatable');
        var productTable = $('#product-datatable');
        var nowDate = new Date();
        var minDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours(), nowDate.getMinutes()-15);

        //BEGIN MASKS

        $(function(){
            $('#cnpj').mask('00.000.000/0000-00');
            $('#valor_minimo').mask('000.000.000.000.000,00', {reverse: true});
            $('#codigo').mask('00000000000000000');
            $('input').each(function() {
                if($(this).val() == '') {
                    $(this).parent('div:first').removeClass('typing');
                } else {
                    $(this).parent('div:first').addClass('typing');
                }
            });
            $('tbody input[type=checkbox]').click(function() {
                let table = $(this).parents('table:first');

                let inputs = table.find('tbody input[type=checkbox]:visible');
                let inputsChecked = inputs.filter(':checked');

                let checkar = (inputs.length == inputsChecked.length);

                table.find('thead input[type=checkbox]:visible').prop('checked', checkar);
            });
            $('#product-datatable tbody tr input[type="checkbox"]:checked').each(function() {
                $(this).parents('tr:first').removeClass('hidden');
            });
        });

        $('input.quantidade').change(function() {
            let value = $(this).val();

            if(!$.isNumeric(value)) {
                $(this).val(1);
                return;
            }

            if(value < 1) {
                $(this).val(1);
                return;
            }

            if(value > 2147483646) { //MAX INT
                $(this).val(2147483646);
            }
        });

        var SPMaskBehavior = function (val) {
                return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
            },
            spOptions = {
                onKeyPress: function(val, e, field, options) {
                    field.mask(SPMaskBehavior.apply({}, arguments), options);
                }
            };

        $('#telefone_representante').mask(SPMaskBehavior, spOptions);
        $('#celular_representante').mask(SPMaskBehavior, spOptions);

        function changeChkProduct() {
            $('#product-datatable').DataTable().search('').draw();
            $('#product-datatable tbody tr input[type="checkbox"]:not(:checked)').each(function() {
                $(this).parents('tr:first').addClass('hidden');
            });
        }

        function changeChkSupplier() {
            let $this = $(this);
            let checked = $this.prop('checked');
            let id = $this.val();
            let check = $('#sendSuppliersTable tbody input[value='+id+']');

            if(checked) {
                let row = $this.parents('tr:first');

                if(check.length == 0) {
                    let tr = $('<tr></tr>');
                    let input = "<label class='mt-checkbox mt-checkbox-outline'><input type='checkbox' name='chkSendSupplier' value='"+id+"' checked/><span></span></label>";

                    tr.append($('<td>'+input+'</td>'));
                    tr.append($('<td>'+row.find('.rep-name').text()+'</td>'));
                    tr.append($('<td>'+row.find('.rep-email').text()+'</td>'));

                    $('#sendSuppliersTable tbody').append(tr);
                }
            } else {
                if(check.length > 0) {
                    check.parents('tr:first').remove();
                }
            }
        };

        //END MASKS


        var token = "{{ token }}";

        {% if userIsRCA %}
            {% if prazoManual == '' %}
                $("#prazo").hide();
            {% endif %}
        $("#prazoRCA").change(function() {
            if($(this).val() == "Outros")
                $('#prazo').show();
            else
                $('#prazo').hide();
        });
        {% endif %}

        $(function () {
            $('#beginsAtTimePicker').datetimepicker({
                format: 'dd/mm/yyyy hh:ii',
                language: 'pt-BR'
            });
            $('#expiresAtTimePicker').datetimepicker({
                format: 'dd/mm/yyyy hh:ii',
                language: 'pt-BR'
            });
        });

        function setItensSuplliers(id,elementId) {
            var count = 0;

            $.each($("#" + id + " tbody tr").find("input"), function(index, value) {
                if($(this)["0"].checked) {
                    count = count + 1
                }
            });
            $("#" + elementId).text(count);<commit_msg>- WebApp: hide calendars after change<commit_after>{% extends 'Retailer/base.html.twig' %}

{% block title %}Adicionar Cotação{% endblock %}
{% block description %}{% endblock %}
{% block menu_pricelist %} active {% endblock %}

{% block page_plugins %}
    <link href="{{ asset('assets/global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css') }}" rel="stylesheet" type="text/css" />

{% endblock %}

{% block page %}
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    <style>
        .ProgressBar {
            margin: 0 auto;
            /*  padding: 2em 0 3em;*/
            list-style: none;
            position: relative;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-pack: justify;
            -ms-flex-pack: justify;
            justify-content: space-between;
            width: auto !important;
        }

        .ProgressBar-step {
            text-align: center;
            position: relative;
            width: 100%;
        }
        .ProgressBar-step:before, .ProgressBar-step:after {
            content: "";
            height: 0.2em;
            background-color: #40AE40;;
            position: absolute;
            z-index: 1;
            width: 100%;
            left: -50%;
            top: 50%;
            -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;

        }
        .ProgressBar-step:first-child:before, .ProgressBar-step:first-child:after {
            display: none;
        }
        .ProgressBar-step:after {
            background-color: #40AE40;
            border:1px solid #40AE40;
            width: 0;
        }
        .ProgressBar-step.is-complete + .ProgressBar-step.is-current:after, .ProgressBar-step.is-complete + .ProgressBar-step.is-complete:after {
            width: 100%;
        }

        .ProgressBar-icon {
            width: 2.0em;
            height: 2.0em;
            background-color: #319431;
            fill: #319431;
            border-radius: 50%;
            padding: 0.5em;
            max-width: 100%;
            z-index: 10;
            position: relative;
            margin-top: 4px;
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;
            border:2px solid #40AE40
        }
        .is-current .ProgressBar-icon {
            fill: yellow;
            background-color: yellow;
        }
        .is-complete .ProgressBar-icon {
            fill: #fff;
            background-color: #40AE40;
        }

        .ProgressBar-stepLabel {
            display: block;
            text-transform: uppercase;
            color: #9F9FA3;
            position: absolute;
            padding-top: 0.5em;
            width: 100%;
            -webkit-transition: all .25s ease-out;
            transition: all .25s ease-out;
        }
        .is-current > .ProgressBar-stepLabel, .is-complete > .ProgressBar-stepLabel {
            color: #00637C;
        }


        /*
        Float label styles
         */
        label:hover {
            cursor: text;
        }

        @media (max-width: 500px) {
            .contact-form {
                margin: 0 0 100px;
                width: 100%;
            }
        }
        .contact-form .email, .contact-form .message, .contact-form .text {
            position: relative;
        }
        .contact-form .email input:focus, .contact-form .email textarea:focus, .contact-form .message input:focus, .contact-form .message textarea:focus, .contact-form .text input:focus, .contact-form .text textarea:focus {
            background: #f4f5f6;
        }
        .contact-form .email label, .contact-form .message label, .contact-form .text label {
            color: #40AE40;
            left: 23px;
            position: absolute;
            top: 13px;
            -moz-transition: all, 150ms;
            -o-transition: all, 150ms;
            -webkit-transition: all, 150ms;
            transition: all, 150ms;
        }
        .contact-form .email.typing label, .contact-form .message.typing label, .contact-form .text.typing label {
            color: #40ae40;
            font-size: 10px;
            top: 2px;
        }

        .text input, .text select {
            margin: 0 auto;
            height: 44px;
            padding-top: 14px;
            width: 95%;
            border: 1px solid #40AE40
        }
        .text input:focus, .text select:focus{
            border: 1px solid #40AE40;
        }

        .contact-form .email {
            border-left: 1px #e6e6e6 solid;
            float: right;
        }
        @media (max-width: 500px) {
            .contact-form .email {
                border-left: none;
                border-top: 1px #e6e6e6 solid;
            }
        }
        .contact-form .message {
            border-bottom: 1px #e6e6e6 solid;
            border-top: 1px #e6e6e6 solid;
            clear: both;
        }
        .contact-form .message textarea {
            height: 200px;
            padding: 23px;
        }
        .contact-form .text {
            float: none;
        }
        .navbar-inner {
            background: #319431;
            width: 100%;
        }

        #rootwizard{
            background: #fff;
        }

        .wizard-container{
            padding: 12px 20px 15px;
            border-top-width: 1px;
        }

        .mt-checkbox.mt-checkbox-outline:hover>input:not([disabled]):checked ~ span, .mt-checkbox.mt-checkbox-outline>input:checked ~ span {

            background: #319431 !important;
            border-radius: 2px;
            border: 1px solid #319431;

        }

        .mt-checkbox.mt-checkbox-outline>span {
            border: 1px solid #d9d9d9;
            background: 0;
            border-radius: 2px;
            cursor: pointer;
        }
        .mt-checkbox>span:after {
            left: 6px;
            top: 2px;
            width: 5px;
            height: 10px;
            border: solid #fff;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
        }

        .error {
            border: 1px solid red !important;
        }

        .valid {
            border: 1px solid #40AE40 !important;
        }

        .nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus {
            color: transparent;
            background-color: transparent;
        }

        .nav>li>a:hover, .nav>li>a:focus {
            text-decoration: none;
            background-color: transparent;
        }
        .disabled-click {
            pointer-events: none;
            cursor: default;
        }
        td {
            text-align: center;
            vertical-align: middle;
        }
        th {
            text-align: center;
            vertical-align: middle;
        }
        .dataTables_filter{

            padding-right: 40px;

        }
        .datatable-plus-button{
            padding-top: 5px;
            top: 14px;
            padding-bottom: 5px;
            padding-right: 9px;
            background: #40AE40;
        }

        .datatable-plus-button::before {
            font-family: fontAwesome;
            content: "\f067\00a0";
            color: white;
            background-color: transparent;
        }

        .text-area{
            width: 95%;
            border: 1px solid #40AE40;
            padding-top: 14px;
            resize: vertical;
            margin-left: 2.5%;
        }

        .text select {
            margin: 0 auto;
            height: 44px;
            padding-top: 14px;
            width: 95%;
            border: 1px solid #40AE40;
        }
        .text select:focus{
            border: 1px solid #40AE40;
        }
        .modal .modal-header{
            background-color: #40AE40;
        }
        .modal-title{
            color: #FFFFFF;
        }

        .ui-autocomplete {
            z-index: 100000;
        }
    </style>

    <div class="page-wrapper-row full-height">
        <div class="page-wrapper-middle">
            <!-- BEGIN CONTAINER -->
            <div class="page-container">
                <!-- BEGIN CONTENT -->
                <div class="page-content-wrapper">
                    <!-- BEGIN CONTENT BODY -->
                    <!-- BEGIN PAGE HEAD-->
                    <div class="page-head">
                        <div class="container">
                            <!-- BEGIN PAGE TITLE -->
                            <div class="page-title">
                                <h1>Cotação
                                    <small>Complete os passos abaixo para criar a sua cotação</small>
                                </h1>
                            </div>
                            <!-- END PAGE TITLE -->
                        </div>
                    </div>
                    <!-- END PAGE HEAD-->
                    <!-- BEGIN PAGE CONTENT BODY -->
                    <div class="page-content">
                        <div class="container">
                            {% include '_partial/flashMessages.html.twig' %}
                            <!-- BEGIN PAGE BREADCRUMBS -->
                            <ul class="page-breadcrumb breadcrumb">
                                <li>
                                    <a href="{{ path('dashboard') }}">Painel Inicial</a>
                                    <i class="fa fa-circle"></i>
                                </li>
                                <li>
                                    <a href="{{ path('cotacoes') }}">Cotações</a>
                                    <i class="fa fa-circle"></i>
                                </li>
                                <li>
                                    <span>Criar Cotação</span>
                                </li>
                            </ul>
                            <!-- END PAGE BREADCRUMBS -->
                            <!-- BEGIN PAGE CONTENT INNER -->
                            <div class="page-content-inner">
                                {{ include('Retailer/pricelist/quoteWizzard.html.twig') }}
                            </div>
                            <!-- END PAGE CONTENT INNER -->
                        </div>
                    </div>
                    <!-- END PAGE CONTENT BODY -->
                    <!-- END CONTENT BODY -->
                </div>
                <!-- END CONTENT -->
            </div>
            <!-- END CONTAINER -->
        </div>
    </div>

    <svg style="display:none" xmlns="http://www.w3.org/2000/svg">
        <symbol id="checkmark-bold" viewBox="0 0 24 24">
            <path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/>
        </symbol>
    </svg>
{% endblock %}

{% block script %}
    <script src="{{ asset('assets/global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.pt-BR.js') }}" type="text/javascript" charset="UTF-8"></script>
    <script src="{{ asset('assets/global/plugins/bootstrap-wizard/jquery.bootstrap.wizard.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/scripts/datatable.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/datatables/datatables.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/jquery-validation/js/jquery.validate.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/global/plugins/jquery-validation/js/localization/messages_pt_BR.min.js') }}" type="text/javascript"></script>
    <script src="{{ asset('assets/pages/scripts/jquery.mask.min.js') }}" type="text/javascript"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

    <script>
        var supplierTable = $('#supplier-datatable');
        var listingTable = $('#listing-datatable');
        var productTable = $('#product-datatable');
        var nowDate = new Date();
        var minDate = new Date(nowDate.getFullYear(), nowDate.getMonth(), nowDate.getDate(), nowDate.getHours(), nowDate.getMinutes()-15);

        //BEGIN MASKS

        $(function(){
            $('#cnpj').mask('00.000.000/0000-00');
            $('#valor_minimo').mask('000.000.000.000.000,00', {reverse: true});
            $('#codigo').mask('00000000000000000');
            $('input').each(function() {
                if($(this).val() == '') {
                    $(this).parent('div:first').removeClass('typing');
                } else {
                    $(this).parent('div:first').addClass('typing');
                }
            });
            $('tbody input[type=checkbox]').click(function() {
                let table = $(this).parents('table:first');

                let inputs = table.find('tbody input[type=checkbox]:visible');
                let inputsChecked = inputs.filter(':checked');

                let checkar = (inputs.length == inputsChecked.length);

                table.find('thead input[type=checkbox]:visible').prop('checked', checkar);
            });
            $('#product-datatable tbody tr input[type="checkbox"]:checked').each(function() {
                $(this).parents('tr:first').removeClass('hidden');
            });
        });

        $('input.quantidade').change(function() {
            let value = $(this).val();

            if(!$.isNumeric(value)) {
                $(this).val(1);
                return;
            }

            if(value < 1) {
                $(this).val(1);
                return;
            }

            if(value > 2147483646) { //MAX INT
                $(this).val(2147483646);
            }
        });

        var SPMaskBehavior = function (val) {
                return val.replace(/\D/g, '').length === 11 ? '(00) 00000-0000' : '(00) 0000-00009';
            },
            spOptions = {
                onKeyPress: function(val, e, field, options) {
                    field.mask(SPMaskBehavior.apply({}, arguments), options);
                }
            };

        $('#telefone_representante').mask(SPMaskBehavior, spOptions);
        $('#celular_representante').mask(SPMaskBehavior, spOptions);

        function changeChkProduct() {
            $('#product-datatable').DataTable().search('').draw();
            $('#product-datatable tbody tr input[type="checkbox"]:not(:checked)').each(function() {
                $(this).parents('tr:first').addClass('hidden');
            });
        }

        function changeChkSupplier() {
            let $this = $(this);
            let checked = $this.prop('checked');
            let id = $this.val();
            let check = $('#sendSuppliersTable tbody input[value='+id+']');

            if(checked) {
                let row = $this.parents('tr:first');

                if(check.length == 0) {
                    let tr = $('<tr></tr>');
                    let input = "<label class='mt-checkbox mt-checkbox-outline'><input type='checkbox' name='chkSendSupplier' value='"+id+"' checked/><span></span></label>";

                    tr.append($('<td>'+input+'</td>'));
                    tr.append($('<td>'+row.find('.rep-name').text()+'</td>'));
                    tr.append($('<td>'+row.find('.rep-email').text()+'</td>'));

                    $('#sendSuppliersTable tbody').append(tr);
                }
            } else {
                if(check.length > 0) {
                    check.parents('tr:first').remove();
                }
            }
        };

        //END MASKS


        var token = "{{ token }}";

        {% if userIsRCA %}
            {% if prazoManual == '' %}
                $("#prazo").hide();
            {% endif %}
        $("#prazoRCA").change(function() {
            if($(this).val() == "Outros")
                $('#prazo').show();
            else
                $('#prazo').hide();
        });
        {% endif %}

        $(function () {
            $('#beginsAtTimePicker').datetimepicker({
                format: 'dd/mm/yyyy hh:ii',
                language: 'pt-BR'
            });
            $('#expiresAtTimePicker').datetimepicker({
                format: 'dd/mm/yyyy hh:ii',
                language: 'pt-BR'
            });

            $('#beginsAtTimePicker').on("dp.change", function (e) {
                $(this).data("datetimepicker").hide();
            });
            $('#beginsAtTimePicker').on("click", function (e) {
                $(this).data("datetimepicker").show();
            });

            $('#expiresAtTimePicker').on("dp.change", function (e) {
                $(this).data("datetimepicker").hide();
            });
            $('#expiresAtTimePicker').on("click", function (e) {
                $(this).data("datetimepicker").show();
            });

        });

        function setItensSuplliers(id,elementId) {
            var count = 0;

            $.each($("#" + id + " tbody tr").find("input"), function(index, value) {
                if($(this)["0"].checked) {
                    count = count + 1
                }
            });
            $("#" + elementId).text(count);
{'fraction_non_alphanumeric': 0.14588221662176645, 'fraction_numerical': 0.026418701659859215, 'mean_word_length': 1.3513145348045226, 'pattern_counts': {'":': 0, '<': 205, '<?xml version=': 0, '>': 239, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 2, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138236', 'n_tokens_mistral': 10395, 'n_tokens_neox': 9384, 'n_words': 1784}