if (($cp->statut == 2 || $cp->statut == 3) && ($user->id == $cp->fk_validator || $user->id == $cp->fk_user)) { $db->begin(); $oldstatus = $cp->statut; $cp->date_cancel = dol_now(); $cp->fk_user_cancel = $user->id; $cp->statut = 4; $result = $cp->update($user->id); if ($result >= 0 && $oldstatus == 3) { // Calculcate number of days consummed $nbopenedday = num_open_day($cp->date_debut_gmt, $cp->date_fin_gmt, 0, 1, $cp->halfday); $soldeActuel = $cp->getCpforUser($cp->fk_user); $newSolde = $soldeActuel + $nbopenedday * $cp->getConfCP('nbHolidayDeducted'); // On ajoute la modification dans le LOG $result1 = $cp->addLogCP($user->id, $cp->fk_user, $langs->transnoentitiesnoconv("HolidaysCancelation"), $newSolde); // Mise à jour du solde $result2 = $cp->updateSoldeCP($cp->fk_user, $newSolde); if ($result1 < 0 || $result2 < 0) { $error = $langs->trans('ErrorCantDeleteCP'); } } if (!$error) { $db->commit(); } else { $db->rollback(); } // Si pas d'erreur SQL on redirige vers la fiche de la demande if (!$error && $result > 0) { // To $destinataire = new User($db); $destinataire->fetch($cp->fk_user); $emailTo = $destinataire->email;
$userValue = price2num($userValue, 5); } else { $userValue = ''; } //If the user set a comment, we add it to the log comment $comment = isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID]) ? ' (' . $_POST['note_holiday'][$userID] . ')' : ''; //print 'eee'.$val['rowid'].'-'.$userValue; if ($userValue != '') { // We add the modification to the log (must be before update of sold because we read current value of sold) $result = $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate') . $comment, $userValue, $val['rowid']); if ($result < 0) { setEventMessages($holiday->error, $holiday->errors, 'errors'); $error++; } // 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 it first update of balance, we set date to avoid to have sold incremented by new month /* $now=dol_now(); $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); $result = $db->query($sql); */ } }
if ($action == 'update' && isset($_POST['update_cp'])) { $userID = array_keys($_POST['update_cp']); $userID = $userID[0]; $userValue = $_POST['nb_holiday']; $userValue = $userValue[$userID]; if (!empty($userValue)) { $userValue = price2num($userValue, 2); } else { $userValue = 0; } //If the user set a comment, we add it to the log comment $comment = isset($_POST['note_holiday'][$userID]) && !empty($_POST['note_holiday'][$userID]) ? ' (' . $_POST['note_holiday'][$userID] . ')' : ''; // We add the modification to the log $holiday->addLogCP($user->id, $userID, $langs->transnoentitiesnoconv('ManualUpdate') . $comment, $userValue); // Update of the days of the employee $holiday->updateSoldeCP($userID, $userValue); // If it first update of sold, we set date to avoid to have sold incremented by new month $now = dol_now(); $sql = "UPDATE " . MAIN_DB_PREFIX . "holiday_config SET"; $sql .= " value = '" . dol_print_date($now, '%Y%m%d%H%M%S') . "'"; $sql .= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. dol_syslog('define_holiday update lastUpdate entry', LOG_DEBUG); $result = $db->query($sql); setEventMessage($langs->trans('UpdateConfCPOK')); } elseif ($action == 'add_event') { $error = 0; if (!empty($_POST['list_event']) && $_POST['list_event'] > 0) { $event = $_POST['list_event']; } else { $error++;
*/ llxHeader(array(), $langs->trans('CPTitreMenu')); print_fiche_titre($langs->trans('MenuConfCP')); $congespayes = new Holiday($db); $listUsers = $congespayes->fetchUsers(false, true); // Si il y a une action de mise à jour if (isset($_POST['action']) && $_POST['action'] == 'update') { $fk_type = $_POST['fk_type']; foreach ($_POST['nb_conges'] as $user_id => $compteur) { if (!empty($compteur)) { $userValue = str_replace(',', '.', $compteur); $userValue = number_format($userValue, 2, '.', ''); } else { $userValue = '0.00'; } $congespayes->updateSoldeCP($user_id, $userValue, $fk_type); } print '<div class="tabBar">'; print $langs->trans('UpdateConfCPOK'); print '</div>'; } $var = true; $i = 0; foreach ($congespayes->getTypes() as $type) { if ($type['affect'] == 1) { print '<div class="tabBar" style="float:left;width:300px;margin-right:10px;">'; print '<h3>' . $type['label'] . '</h3>'; print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">' . "\n"; print '<input type="hidden" name="action" value="update" />'; print '<input type="hidden" name="fk_type" value="' . $type['rowid'] . '" />'; print '<table class="noborder" width="100%;">';