Exemple #1
0
// If the user does not have perm to read the page
if (!$user->rights->holiday->define_holiday) {
    accessforbidden();
}
$action = GETPOST('action');
/*
 * View
 */
$form = new Form($db);
$userstatic = new User($db);
$holiday = new Holiday($db);
llxHeader(array(), $langs->trans('CPTitreMenu'));
print_fiche_titre($langs->trans('MenuConfCP'));
$holiday->updateSold();
// Create users into table holiday if they don't exists. TODO Remove if we use field into table user.
$listUsers = $holiday->fetchUsers(false, false);
// Si il y a une action de mise à jour
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);
require_once DOL_DOCUMENT_ROOT . '/holiday/common.inc.php';
// Protection if external user
if ($user->societe_id > 0) {
    accessforbidden();
}
// If the user does not have perm to read the page
if (!$user->rights->holiday->define_holiday) {
    accessforbidden();
}
/*
 * View
 */
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>';