AnonSec Shell
Server IP : 162.214.74.102  /  Your IP : 216.73.216.192
Web Server : Apache
System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64
User : lrsys ( 1015)
PHP Version : 5.6.40
Disable Function : exec,passthru,shell_exec,system
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/lrsys/www/lrsys_apps/leo/application/plugins/module_fish/assets/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/lrsys/www/lrsys_apps/leo/application/plugins/module_fish/assets/js/movement-add.js
/* global ind_mil, ind_decimal, block_msg, toast, bootbox, _L */

$(document).ready(function ()
{
   
     
    findDataSelect("#crm_accounts_id", $("#_client_view").val()+'module_fish/ajax/Associated', '');
    findDataSelect("#client_id",$("#_client_view").val()+'module_fish/ajax/Associated/Customer', '');
    $('.amount').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 2, aSign: curr_code+' '});

    var rowNum=1;
    $("#emsg").hide();
    
        $("#submit").on('click', function (e) {
           if($("#close").val()==undefined){
                   bootbox.alert(_L['Module_Fish Select tank origin']);
            } else{
                if(($("#close").prop("checked") == true && $("#qty_restant").val()==0) || $("#close").prop("checked") == false){
                     e.preventDefault();
                    $("#ibox-form").block({message: block_msg});
                           $.post($("#_url").val() +$("#_client_view").val()+ "module_fish/movement/post", $("#form-movement").serialize())
                             .done(function (retorno) {
                                    var data = JSON.parse(retorno);
                                    if (data.status == 'OK') {
                                        location.reload();
                                    } else {
                                        $("#ibox-form").unblock();
                                        var body = $("html, body");
                                        body.animate({scrollTop: 0}, '1000', 'swing');
                                        $("#emsgbody").html(data.msg);
                                        $("#emsg").show("slow");
                                    }
                                });

                }else{
                    bootbox.alert(_L['Module_Fish Is necessarie clear qtd restant tank']);
                }
        }

    });
   
    var crm_accounts_id="";
    var module_fish_lots_distribuition_id="";
    if($("#_client_view").val()!=""){
        findDataSelect("#module_fish_lots_distribuition_id", $("#_client_view").val()+'module_fish/ajax/lotsTankAssociated/'+$("#crm_accounts_id").val() , '');
    }
             
    $('#crm_accounts_id').on('change', function () {
        var qtds = document.getElementsByName('tank[]');
        if (module_fish_lots_distribuition_id!="" && module_fish_lots_distribuition_id!=null && ($("#crm_accounts_id").val() != crm_accounts_id && crm_accounts_id != "" && crm_accounts_id != null)) {
                bootbox.confirm(_L['All movement destiny will be removed, it will be necessary to re-register them. You Want do Continue?'], function (result) {
                    if (result) {
                        crm_accounts_id= $("#crm_accounts_id").val();
                        clearDataDestiny();   
                        findDataSelect("#module_fish_lots_distribuition_id",$("#_client_view").val()+ 'module_fish/ajax/lotsTankAssociated/'+$("#crm_accounts_id").val(), '');
                        $("#module_fish_lots_distribuition_id").val("").trigger("change");
                        $("#table_destin").addClass("hide");
                    } else {
                        $("#crm_accounts_id").val(crm_accounts_id).trigger("change");
                    }
                });
        }else{
            if(crm_accounts_id!= $("#crm_accounts_id").val()){
                crm_accounts_id= $("#crm_accounts_id").val();
                findDataSelect("#module_fish_lots_distribuition_id", $("#_client_view").val()+'module_fish/ajax/lotsTankAssociated/'+$(this).val(), '');
                $("#module_fish_lots_distribuition_id").val("").trigger("change");
                $("#table_destin").addClass("hide");
            }
       }
     
    
    });

    $(".hr").mask("99:99");

    $(".hr").on("keyup", function () {
        validate = $(this).val().split(":");
        if ((validate[0] > 23) ||
                (validate[1] > 59)) {
            $(this).val('');
            $(this).focus();
            return;
        }
    });


    $('#module_fish_lots_distribuition_id').on('change', function () {
        var qtds = document.getElementsByName('tank[]');
     
        if ($("#module_fish_lots_distribuition_id").val()!=null && $("#module_fish_lots_distribuition_id").val()!="" && qtds.length > 0 && ($("#module_fish_lots_distribuition_id").val() != module_fish_lots_distribuition_id && module_fish_lots_distribuition_id != "" && module_fish_lots_distribuition_id != null)) {
                bootbox.confirm(_L['All movement destiny will be removed, it will be necessary to re-register them. You Want do Continue?'], function (result) {
                    if (result) {
                        module_fish_lots_distribuition_id= $("#module_fish_lots_distribuition_id").val();
                        clearDataDestiny();    
                        findDataLote();
                        $("#table_destin").removeClass("hide");
                    } else {
                        $("#module_fish_lots_distribuition_id").val(module_fish_lots_distribuition_id).trigger("change");
                    }
                });
        }else{
            module_fish_lots_distribuition_id= $("#module_fish_lots_distribuition_id").val();
            findDataLote();
            if($(this).val()!=""){
                $("#table_destin").removeClass("hide");
            }else{
                $("#table_destin").addClass("hide");
                clearDataDestiny();    
            }
        }
       
    });
    
    $('#date').on('blur change', function (event) {
        if ($(this).val() == '') {
            $('#date').val($("#date_start").val());
        }
        findDataLote();
    });
    
    function findDataLote(){
        $.post($("#_url").val()+$("#_client_view").val() + "module_fish/movement/data_lote", {module_fish_lots_distribuition_id:$("#module_fish_lots_distribuition_id").val(),date:$("#date").val()})
        .done(function (retorno) {
            $("#data-lote").html(retorno);
            $("#close").on('change', function () {
               if($(this).prop("checked") == true){
                    if($("#type").val()!='transfer'){
                        $('#qty_0').attr('readonly','readonly');
                        $('#qty_0').val($("#qty_actual").val());
                        $('#item-add').addClass("hide");
                    }else{
                        $('#item-add').removeClass("hide");
                    }
                    
                    $('#weight_restant').attr('readonly','readonly');
                    $('#weight_restant').val(0);
                    calculate();
                   
                }  else{
                    $('#weight_restant').removeAttr('readonly');
                    $('#qty_0').removeAttr('readonly'); 
                 
                    
               }
           });
            calculate();
        });
    }
    
    
    $("#table_destin").on("blur", ".verifyValues", function (e) {
       calculate();
    });
    $("#table_destin").on("blur", ".biomass", function (e) {
        if($(this).val()!=""){
            var value= formatValueJs($(this).val());
            if($("#qty_"+$(this).attr("data-row")).val()!=""){
                var newWeight=parseInt((value*1000)/$("#qty_"+$(this).attr("data-row")).val());
                $("#weight_"+$(this).attr("data-row")).val(newWeight);
                calculate();   
            } 
        }
    });
    $("#table_destin").on("blur keyup", ".qty", function (e) {
        
        var total= 0;
        $('.qty').each(function (f) {
            total+= formatInt($(this).val()==""?0:$(this).val());
        });
        if($("#type").val()!='recont'){
            if($("#qty_actual").val()!== undefined && $("#qty_actual").val()!==""){
                var qty_actual=formatInt($("#qty_actual").val());
            }else{
                  var qty_actual=0;
            }
            if(total>qty_actual){
                $(this).val(formatInt($(this).val()==""?0:$(this).val())-(total-qty_actual));
            }
        }
        calculate();
    });
    
    $("#table_origin").on("blur", "#weight_restant", function (e) {
       calculate();
    });    

    
    function clearDataDestiny(){
        $("#table_destin").html(destinyHtmlStart);
        selectNotInTank("#tank_0");
    }
    var destinyHtmlStart=  $("#table_destin").html();
    
    selectNotInTank("#tank_0");
    $('#qty_0').autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
    $('#qty_restant').autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
    $('#weight_restant').autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
    $('#weight_0').autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
    $('#biomass_0').autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 3, aSign:''});

    
    //adição de novos opções de tanqyes

    $("#table_destin").on("click", "#item-add", function (e) {
        $("#table_destin").find('tbody')
                .append('<tr>\n\
                            <td> <input type="hidden" name="row[]" value="'+rowNum+'"><div class="data-tank"><select class="form-control tank" style="width:100%" data-row="'+rowNum+'"   id="tank_'+rowNum+'" name="tank_'+rowNum+'"></select>\n\
                           <div class="hide" id="select_program_'+rowNum+'"> \n\
                            <label>'+_L['Module_Fish Program']+'</label>\n\
                             <select data-row="' + rowNum + '"  id="program_' + rowNum + '" name="program_'+rowNum+'"  class="form-control program_select" style="width:100%"></select></div>  </div>    <input type="hidden" name="program_required_'+rowNum+'" id="program_required_'+rowNum+'" value="0">  </td>\n\
                            <td><input type="text" class="form-control qty"  id="qty_'+rowNum+'" data-row="'+rowNum+'"  name="qty_'+rowNum+'" value=""></td>\n\
                            <td class=" ">\n\
                                <div class="input-group">\n\
                                    <input class="form-control verifyValues" id="weight_'+rowNum+'"  data-row="'+rowNum+'" name="weight_'+rowNum+'" style="min-width:100px;" type="text" value="">\n\
                                    <span class="input-group-addon">g</span>\n\
                                </div>\n\
                            </td>\n\
                            <td class="col-xs-1"><input  data-row="'+rowNum+'"  type="text" class="form-control biomass" name=""  id="biomass_'+rowNum+'" value=""></td><td><a href="#" id="delete_'+rowNum+'"  class="btn btn-xs btn-danger delete"><i class="fa fa-trash"></i></a>\n\
                        </tr>'
                        );
        $('[data-toggle="tooltip"]').tooltip();
        findDataSelect("#program_" + rowNum, 'module_fish/ajax/program/', '');
        selectNotInTank('#tank_'+rowNum);
        $('#qty_'+rowNum).autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
        $('#weight_'+rowNum).autoNumeric('init', {aSep: '', aDec: ind_decimal, mDec: 0});
        $('#biomass_'+rowNum).autoNumeric('init', {aSep: ind_mil, aDec: ind_decimal, mDec: 3, aSign:''});
        rowNum++;
             
     });
        
    $("#table_destin").on("click", ".delete", function (e) {
        $(this).closest('tr').remove();
        calculate();
    });

    $("#table_destin").on("change", ".tank", function (e) {
         tank=$(this);
         $.post($("#_url").val()+$("#_client_view").val() + "module_fish/movement/verifyTankLote", {module_fish_lots_distribuition_id:$("#module_fish_lots_distribuition_id").val(),module_fish_tank_id:$(this).val()})
        .done(function (retorno) {
                if(retorno==0){
                    $("#select_program_"+tank.attr("data-row")).removeClass("hide");
                    findDataSelect("#program_"+tank.attr("data-row"), 'module_fish/ajax/program/', '');
                    $("#program_required_"+tank.attr("data-row")).val(1);
                }else{
                    $("#select_program_"+tank.attr("data-row")).addClass("hide");
                    $("#program_required_"+tank.attr("data-row")).val(0);
                }
           });
    });


    $("#type").on("change", function (e) {
        if($('#type').val()!='transfer'){
            $(".data-tank").addClass("hide");
            for(i=1;i<rowNum;i++){
                $("#delete_"+i).click();
            }
            
            if($("#close").prop("checked") == true){
                $('#qty_0').attr('readonly','readonly');
                $('#qty_0').val($("#qty_actual").val());

            }else{
                $('#qty_0').removeAttr('readonly');

            }
            $('#item-add').addClass("hide");
            if($("#type").val()=='sale'){
                $(".sale").removeClass('hide');
            }else{
                $(".sale").addClass('hide');
            }
                    
        }else{
            $(".data-tank").removeClass("hide");
            $('#qty_0').removeAttr('readonly');
            $('#item-add').removeClass("hide");
                    
        }
    });
});

function selectNotInTank(componente){
      $(componente).select2({
        theme: "bootstrap",
        placeholder:"",
        ajax: {
                url: $("#_url").val()+$("#_client_view").val()+"module_fish/ajax/tankAssociated",
                dataType: "json",
                delay: 250,
                method: "POST",
                data: function (params) {
                    var queryParameters = {
                            term: params.term,
                            notin: returnFields(".tank")+","+$("#module_fish_tank_id_origin").val(),
                            crm_accounts_id:$('#crm_accounts_id').val()
                    };
                    return queryParameters;
                },
                processResults: function (data) {
                    return {
                        results: $.map(data, function (item) {
                            return {
                                text: item.text,
                                id: item.id
                            }
                        })
                    };
                },
                cache: true,   
        }
    });
}
//funcção que calcula os valores para a tela
function calculate(){
    if($('#type').val()!='transfer'){
        $(".data-tank").addClass("hide");
    }else{
        $(".data-tank").removeClass("hide");
    }
    
    if($("#qty_actual").val()!== undefined && $("#qty_actual").val()!==""){
        var qty_actual=formatInt($("#qty_actual").val());
    }else{
        var qty_actual=0;
    }
    var total= 0;
    var total_biomass= 0;
    
    $('.qty').each(function (f) {
        total+= formatInt($(this).val()==""?0:$(this).val());
        biomass=formatInt($(this).val()==""?0:$(this).val())*formatValueJs(($('#weight_' +$(this).attr('data-row')).val()!=""?$('#weight_' +$(this).attr('data-row')).val():0))/1000;
        $('#biomass_' + $(this).attr('data-row')).val(formatDecimal3(parseFloat(biomass).toFixed(3)+""));
        total_biomass+=biomass;
    });
    if($("#type").val()=='recont'){
        $("#qty_restant").val(parseInt(qty_actual));
        biomass_restant=((parseInt(qty_actual))*(formatValueJs($('#weight_restant').val()!=''?$('#weight_restant').val():0)))/1000;
        $("#total_qty").html(parseInt(qty_actual)+parseInt(total));
    }else{
        $("#qty_restant").val(parseInt(qty_actual)-parseInt(total));
        biomass_restant=((parseInt(qty_actual)-parseInt(total))*(formatValueJs($('#weight_restant').val()!=''?$('#weight_restant').val():0)))/1000;
        $("#total_qty").html(total+parseInt(qty_actual)-parseInt(total));
    }
    $("#biomass_restant").val(formatDecimal3(parseFloat(biomass_restant).toFixed(3)+ ""));
  
    totalFinal=parseFloat((total_biomass)+(biomass_restant)).toFixed(3);
    $("#total_biomass").html(formatDecimal3(totalFinal+""));
}


function returnFields(f) {
    var retorno = "";
    $(f).each(function (e) {
        if ($(this).val() != "" && $(this).val() != null) {
            retorno += "," + $(this).val();
        }
    });
    return retorno;
}

Anon7 - 2022
AnonSec Team