Debug v16

This commit is contained in:
Laurent Destailleur 2022-08-12 15:07:15 +02:00
parent 3c65841e19
commit 0d68c0ba14
3 changed files with 42 additions and 21 deletions

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2007-2016 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2022 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Regis Houssin <regis.houssin@inodbox.com>
@ -130,12 +130,15 @@ if (empty($reshook)) {
// Si il y a une action de mise à jour
if ($action == 'update' && GETPOSTISSET('update_cp')) {
$error = 0;
$nbok = 0;
$typeleaves = $holiday->getTypes(1, 1);
$userID = array_keys(GETPOST('update_cp'));
$userID = $userID[0];
$db->begin();
foreach ($typeleaves as $key => $val) {
$userValue = GETPOST('nb_holiday_'.$val['rowid']);
$userValue = $userValue[$userID];
@ -150,20 +153,26 @@ if (empty($reshook)) {
$note_holiday = GETPOST('note_holiday');
$comment = ((isset($note_holiday[$userID]) && !empty($note_holiday[$userID])) ? ' ('.$note_holiday[$userID].')' : '');
//print 'holiday: '.$val['rowid'].'-'.$userValue;
//print 'holiday: '.$val['rowid'].'-'.$userValue;exit;
if ($userValue != '') {
// We add the modification to the log (must be before update of sold because we read current value of sold)
// We add the modification to the log (must be done before the update of balance because we read current value of balance inside this method)
$result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate').$comment, $userValue, $val['rowid']);
if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
} elseif ($result == 0) {
setEventMessages($langs->trans("HolidayQtyNotModified", $user->login), null, 'warnings');
}
// Update of the days of the employee
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
if ($result > 0) {
$nbok++;
$result = $holiday->updateSoldeCP($userID, $userValue, $val['rowid']);
if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
$error++;
}
}
// If it first update of balance, we set date to avoid to have sold incremented by new month
@ -179,7 +188,13 @@ if (empty($reshook)) {
}
if (!$error) {
setEventMessages('UpdateConfCPOK', '', 'mesgs');
$db->commit();
if ($nbok > 0) {
setEventMessages('UpdateConfCPOK', '', 'mesgs');
}
} else {
$db->rollback();
}
}
}

View File

@ -159,15 +159,15 @@ if (empty($reshook)) {
// Definition of fields for lists
$arrayfields = array(
'cpl.rowid'=>array('label'=>$langs->trans("ID"), 'checked'=>1),
'cpl.date_action'=>array('label'=>$langs->trans("Date"), 'checked'=>1),
'cpl.fk_user_action'=>array('label'=>$langs->trans("ActionByCP"), 'checked'=>1),
'cpl.fk_user_update'=>array('label'=>$langs->trans("UserUpdateCP"), 'checked'=>1),
'cpl.type_action'=>array('label'=>$langs->trans("Description"), 'checked'=>1),
'cpl.fk_type'=>array('label'=>$langs->trans("Type"), 'checked'=>1),
'cpl.prev_solde'=>array('label'=>$langs->trans("PrevSoldeCP"), 'checked'=>1),
'variation'=>array('label'=>$langs->trans("Variation"), 'checked'=>1),
'cpl.new_solde'=>array('label'=>$langs->trans("NewSoldeCP"), 'checked'=>1),
'cpl.rowid'=>array('label'=>"ID", 'checked'=>1),
'cpl.date_action'=>array('label'=>"Date", 'checked'=>1),
'cpl.fk_user_action'=>array('label'=>"ActionByCP", 'checked'=>1),
'cpl.fk_user_update'=>array('label'=>"UserUpdateCP", 'checked'=>1),
'cpl.type_action'=>array('label'=>"Description", 'checked'=>1),
'cpl.fk_type'=>array('label'=>"Type", 'checked'=>1),
'cpl.prev_solde'=>array('label'=>"PrevSoldeCP", 'checked'=>1),
'variation'=>array('label'=>"Variation", 'checked'=>1),
'cpl.new_solde'=>array('label'=>"NewSoldeCP", 'checked'=>1),
);
@ -403,7 +403,7 @@ print '</tr>';
print '<tr class="liste_titre">';
if (!empty($arrayfields['cpl.rowid']['checked'])) {
print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'rowid', '', '', '', $sortfield, $sortorder);
print_liste_field_titre($arrayfields['cpl.rowid']['label'], $_SERVER["PHP_SELF"], 'cpl.rowid', '', '', '', $sortfield, $sortorder);
}
if (!empty($arrayfields['cpl.date_action']['checked'])) {
print_liste_field_titre($arrayfields['cpl.date_action']['label'], $_SERVER["PHP_SELF"], 'date_action', '', '', '', $sortfield, $sortorder, 'center ');
@ -484,7 +484,7 @@ while ($i < min($num, $limit)) {
// Description
if (!empty($arrayfields['cpl.type_action']['checked'])) {
print '<td>'.$holidaylogstatic->description.'</td>';
print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($holidaylogstatic->description).'">'.dol_escape_htmltag($holidaylogstatic->description).'</td>';
}
// Type
@ -510,8 +510,13 @@ while ($i < min($num, $limit)) {
// Variation
if (!empty($arrayfields['variation']['checked'])) {
$delta = price2num($holidaylogstatic->balance_new - $holidaylogstatic->balance_previous, 5);
$detasign = ($delta > 0 ? '+' : '');
print '<td style="text-align: right;">'.$detasign.$delta.'</td>';
print '<td style="text-align: right;">';
if ($delta > 0) {
print '<span class="stockmovemententry fontsizeunset">+'.$delta.'</span>';
} else {
print '<span class="stockmovementexit fontsizeunset">'.$delta.'</span>';
}
print '</td>';
}
// New Balance

View File

@ -137,3 +137,4 @@ XIsAUsualNonWorkingDay=%s is usualy a NON working day
BlockHolidayIfNegative=Block if balance negative
LeaveRequestCreationBlockedBecauseBalanceIsNegative=The creation of this leave request is blocked because your balance is negative
ErrorLeaveRequestMustBeDraftCanceledOrRefusedToBeDeleted=Leave request %s must be draft, canceled or refused to be deleted
HolidayQtyNotModified=Balance of remaining days for %s has not been changed