pass Jquery parameter to PHP

0

I ask for your support to guide me with the following problem:

this instruction causes jquery to calculate the salary of an employee, but only the payroll, that is:

if someone wins 10 thousand Mexican pesos, or any other denomination.

Of those 10 thousand, there is a part of the salary that is considered payroll, the rest is paid as another concept.

for example: for 10 thousand, 3600 are payroll, the remaining 6400 is a commission.

those 3600 are stored in the database and apart from PHPExcel use to get a report where this information comes, what I need to know is how to make that value is passed to a variable PHP (Codeingiter 2), that salary of payroll need PHP can calculate it, in the case that the employee came to work from the first day of the fortnight is paid the full payroll, if not entered from the beginning of fortnight, you will be paid the proprocional, of course If the employee already exists before, his payroll is also complete, I hope to understand.

in case it is easier to continue using jquery to do the calculation and that same information can be included in the report that came out of excel, I would greatly appreciate your input.

This code was not done by me, however I would like to avoid deleting it and having to do everything again, if it is possible to correct it.

Greetings.

    $('#sueldo_total').blur(function(){
        //alert( this.value);
        if( $('#sueldo_total').val()=='' ) return false;

        var total = parseFloat($(this).val());            
        var sn = parseInt($('#sueldo_nomina').val());
       <?php
        if (($ion_user->group == 'rh')) {
        ?>
        if(sn >= 0 && total > 0 && $('#sueldo_nomina').val() != '') {

            s_nom = parseInt($('#sueldo_nomina').val());

            if(total<s_nom) {
                alert('El valor no puede ser menor al sueldo de nómina');
                return false;
            }

            if(total>=s_nom){

              s_com = total - s_nom;  
            } 

            $('#sueldo_comision').val(redondear(s_com));

            return false;            
        }
        <?php } ?>

        var s_com = 0;
        var s_nom = 0;
        $.ajax({
            data: 'ajax=1',
            url: base_url + 'ajax/obtener_empresa_nomina/'+ $(this).val(),
            dataType: 'json',
            cache: false,
            type: 'POST',
            success: function(data) {
                s_nom = parseInt(data.cantidad);

                $('#id_empresa').val(data.id_empresa);
                $('#id_empresa_ver').val(data.id_empresa);
                if(total>=s_nom) {
                    $('#sueldo_nomina').val(data.cantidad);
                }
                else{

                    $('#sueldo_nomina').val(total);
                } 


                if(total>=s_nom){
                    s_com = total - s_nom;

                } 

                $('#sueldo_comision').val(redondear(s_com));
            },
            error: function(data) {
                //error('No se pudo eliminar el registro. Compruebe que no se encuentra en uso actualmente.');
            }
        });
    });
    
asked by Javier 12.04.2018 в 21:35
source

0 answers