I developed an application that generates Holerites, and for that I need to treat data coming from 4 tables.
Officials - > Companies - > Maturities - > Discounts
I want to show my user this way for example:
Rafael works in company X and has 10 salaries and 20 discounts.
Sample Code:
$total_vencimento= 0;
$total_desconto = 0;
// Aqui em funcionários realizei um join com empresas.
foreach ($funcionarios as $funcionario) {
foreach ($vencimentos as $vencimento) {
//VERIFICA SE PERTENCE AO FUNCIONARIO ATUAL E PRINTA
$total_vencimento += $vencimento->valor;
}
foreach ($descontos as $desconto) {
//VERIFICA SE PERTENCE AO FUNCIONARIO ATUAL E PRINTA
$total_desconto += $desconto->valor;
}
// Aqui apresentaria o valor liquido entra Vencimentos - Descontos
}
I would like to know the best way to perform a query or procedure by PHP itself, in order to generate these Holerites. I'm going to generate the Holerites based on the company ID. The user will select the company and will generate the Holerites of all the employees, describing the names of the Maturities and Discounts and their values.
I am currently bringing all employees belonging to the company, and their respective salaries and discounts. All this in a foreach and Czech if that expiration / discount belongs to the current employee of the loop and printo.