Commit f47451aa authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Gestion des horaires dans la fiche personne et dans les paramètres...

Gestion des horaires dans la fiche personne et dans les paramètres utilisateur. Ajout des privilèges, préparation du mode soumission des horaires (en attente de validation métier)
parent ff93d2eb
Loading
Loading
Loading
Loading
+42 −1
Changes for config/autoload/global.php: 42 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -87,6 +87,48 @@ return array(
        'declarationsMonthDuration' => 144.0,
        'declarationsMonthDurationMaxlength' => 176.0,

        'userSubmitSchedule' => false,
        'userSubmitScheduleValidateByNp1' => true,
        'userSubmitScheduleValidateByPrivilege' => \Oscar\Provider\Privileges::PERSON_MANAGE_SCHEDULE,

        'scheduleModeles' => [
            'fulltime' => [
                'label' => 'Plein temps',
                'week' => 35.0,
                'days' => [
                    1 => 7.0,
                    2 => 7.0,
                    3 => 7.0,
                    4 => 7.0,
                    5 => 7.0
                ]
            ],

            'halftime' => [
                'label' => 'Mi-temps',
                'week' => 17.5,
                'days' => [
                    1 => 3.5,
                    2 => 3.5,
                    3 => 3.5,
                    4 => 3.5,
                    5 => 3.5
                ]
            ],

            'parttime' => [
                'label' => 'Mi-temps',
                'week' => 30.0,
                'days' => [
                    1 => 6.0,
                    2 => 6.0,
                    3 => 6.0,
                    4 => 6.0,
                    5 => 6.0
                ]
            ],
        ],

        // Configuration des cas particuliers (LABS)
        'declarationsDurations' => [

@@ -94,7 +136,6 @@ return array(
                'value' => 7.5,
                'max' => 10.0,
                'min' => 5.0,
                'userChange' => false,
                'days' => [
                    '1' => 7.5,
                    '2' => 7.5,
+10
Changes for install/privileges.json: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@
    "category_id": 2,
    "root": "ACTIVITY-MILESTONE_SHOW",
    "spot": 7,
    "spot": 7,
    "code": "MILESTONE_PROGRESSION",
    "libelle": "Peut g\u00e9rer l'état d'avancement des jalons",
    "fullcode": "ACTIVITY-MILESTONE_PROGRESSION"
@@ -316,6 +317,15 @@
    "fullcode": "PERSON-MANAGE_SCHEDULE"
  },

  "PERSON-SHOW_SCHEDULE": {
    "category_id": 3,
    "root": "PERSON-SHOW",
    "spot": 7,
    "code": "SHOW_SCHEDULE",
    "libelle": "Peut  voir la répartition horaire d'une personne",
    "fullcode": "PERSON-SHOW_SCHEDULE"
  },

  "PERSON-EDIT": {
    "category_id": 3,
    "spot": 4,
+4 −17
Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 4 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -512,22 +512,9 @@ class PersonController extends AbstractOscarController
                        $this->getOscarUserContext()->check(Privileges::PERSON_MANAGE_SCHEDULE);

                        try {
                            $daysLength = json_decode($this->params()->fromPost('days'));
                            $allowDays = ['1', '2', '3', '4', '5'];

                            // Tester l'authorisation de déclarer le weekend
                            $datas = ['days' => []];
                            foreach ($daysLength as $day=>$duration) {
                                if( in_array($day, $allowDays) ){
                                    $value = floatval($duration);
                                    if( is_float($value) ){
                                        $datas['days'][$day] = $value;
                                    }
                                }
                            }

                            $person->setCustomSettingsObj($datas);
                            $this->getEntityManager()->flush($person);
                            $daysLength = $this->params()->fromPost('days');
                            $this->getUserParametersService()->performChangeSchedule($daysLength, $person);
                            return $this->getResponseOk("Heures enregistrées");
                        } catch (\Exception $e) {
                            return $this->getResponseInternalError("Impossible d'enregistrer les paramètres : " . $e->getMessage());
                        }
@@ -535,7 +522,6 @@ class PersonController extends AbstractOscarController
                    }

                    $datas = $timesheetService->getDayLengthPerson($person);

                    return $this->ajaxResponse($datas);
                    break;
                default:
@@ -601,6 +587,7 @@ class PersonController extends AbstractOscarController
            'schedule'  => $timesheetService->getDayLengthPerson($person),
            'entity' => $person,
            'ldapRoles' => $roles,
            'scheduleEditable' => $this->getOscarUserContext()->hasPrivileges(Privileges::PERSON_MANAGE_SCHEDULE),
            'referents' => $referents,
            'subordinates' => $subordinates,
            'authentification' => $this->getEntityManager()->getRepository(Authentification::class)->findOneBy(['username' => $person->getLadapLogin()]),
+27
Changes for module/Oscar/src/Oscar/Controller/PublicController.php: 27 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,32 @@ class PublicController extends AbstractOscarController
        // Récupération des envois automatiques
        $forceSend = $this->getConfiguration('oscar.notifications.fixed');

        $method = $this->getHttpXMethod();


        // Traitment des horaires
        if( $this->isAjax() && $this->params()->fromQuery('a') == 'schedule' ){

            /** @var TimesheetService $timesheetService */
            $timesheetService = $this->getServiceLocator()->get('TimesheetService');

            if( $method == 'GET' ){
                $datas = $timesheetService->getDayLengthPerson($this->getCurrentPerson());
                return $this->ajaxResponse($datas);
            }
            elseif ($method == 'POST'){

                $schedule = $this->params()->fromPost('days');
                try {
                    $this->getUserParametersService()->performChangeSchedule($schedule, $this->getCurrentPerson(), false);
                    return $this->getResponseOk();
                } catch ( OscarException $e ){
                    return $this->getResponseInternalError(sprintf('%s : %s', _('Impossible de modifier la répartition horaire'), $e->getMessage()));
                }
            }

        }

        if( $this->getHttpXMethod() == "POST" ){
            $action = $this->params()->fromPost('action');

@@ -83,6 +109,7 @@ class PublicController extends AbstractOscarController
            'subordinates' => $this->getPersonService()->getSubordinates($this->getCurrentPerson()),
            'managers' => $this->getPersonService()->getManagers( $this->getCurrentPerson()),
            'subordonates' => $this->getPersonService()->getSubordinates( $this->getCurrentPerson()),
            'scheduleEditable' => $this->getUserParametersService()->scheduleEditable(),
            'declarationsConfiguration' => null, //$timesheetService->getDeclarationConfigurationPerson($this->getCurrentPerson()),
            'person' => $this->getCurrentPerson(),
            'declarationsHours' => $declarationsHours,
+1
Changes for module/Oscar/src/Oscar/Provider/Privileges.php: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ class Privileges extends \UnicaenAuth\Provider\Privilege\Privileges

    const PERSON_SHOW               = 'PERSON-SHOW';
    const PERSON_EDIT               = 'PERSON-EDIT';
    const PERSON_SHOW_SCHEDULE      = 'PERSON-SHOW_SCHEDULE';
    const PERSON_MANAGE_SCHEDULE    = 'PERSON-MANAGE_SCHEDULE';
    const PERSON_SYNC_LDAP = 'PERSON-SYNC_LDAP';
    const PERSON_PROJECTS = 'PERSON-PROJECTS';
Loading