I need some guidance and hope you can help me, I have a project done in CI 2, which pays the salary to an employee on a monthly basis, the problem that I present is that if a person goes to work after being paid salaries, his salary would be paid until the next payment next month, I have problems to calculate the salary of the month in which the employee entered and that this supplement is added to the next month's salary, I think the problem is in the ELSE
I think it should be like this formatted date, if someone knows how I can do so that the code calculates the days worked since the employee was registered until the last day of the month I will thank you (note: in my project every month of the year have 30 days)
$alta = strtotime($comisionista->fecha_ingreso);
if ($fecha_ultimo_pago != NULL && $alta >= $fecha_ultimo_pago) {
$dias = 0;
//Para descontar dias
if (date('Y-m', $alta) == date('Y-m'))
$dias = -1 * ($alta - strtotime(date('Y-m-1'))) / (60 * 60 * 24);
else
{
$dias = (strtotime(mktime(0, 0, 0, (int) date('n'), 1, date('Y')) - $alta )) / (60 * 60 * 24);
$monthbefore = strtotime(mktime(0, 0, 0, ((int) date('m')-1), 1, date('Y')));
$diasma = date ('t',$monthbefore );
if($diasma > 30)
$dias = $dias-1;
}