Commit df6bc16e authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Système d'affichage et de modification horaire en cours

parent 5039aeef
Loading
Loading
Loading
Loading
+4 −7
Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 4 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ use Oscar\Hydrator\PersonFormHydrator;
use Oscar\Provider\Person\SyncPersonHarpege;
use Oscar\Service\PersonnelService;
use Oscar\Service\PersonService;
use Oscar\Service\TimesheetService;
use Oscar\Utils\UnicaenDoctrinePaginator;
use Zend\Http\Response;
use Zend\View\Model\JsonModel;
@@ -48,13 +49,6 @@ class PersonController extends AbstractOscarController
        $this->getResponseDeprecated();
    }

    public function personFusionAction()
    {

    }



    public function viewsAction()
    {
        $view = $this->params()->fromQuery('view', 'almoststart');
@@ -554,8 +548,11 @@ class PersonController extends AbstractOscarController
        $referents = $this->getPersonService()->getReferentsPerson($person);
        $subordinates = $this->getPersonService()->getSubordinatesPerson($person);

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

        return [
            'schedule'  => $timesheetService->getDayLengthPerson($person),
            'entity' => $person,
            'ldapRoles' => $roles,
            'referents' => $referents,
+1 −14
Changes for module/Oscar/src/Oscar/Entity/ValidationPeriod.php: 1 added line, 14 removed lines.
Original line number Diff line number Diff line
@@ -432,18 +432,6 @@ class ValidationPeriod
            ->setStatus(self::STATUS_CONFLICT);
    }



//$period->setRejectActivity($validateur, new \DateTime(), $message);
//break;
//
//case ValidationPeriod::STATUS_STEP2:
//$period->setRejectSci($validateur, new \DateTime(), $message);
//break;
//
//case ValidationPeriod::STATUS_STEP3:
//$period->setRejectAdm($validateur, new \DateTime(), $message);

    /**
     * Peut être validé niveau projet par la personne.
     *
@@ -1117,6 +1105,7 @@ class ValidationPeriod
        $msg = $date->format(sprintf('Y-m-d H:i:s %s %s', $by, $message));
        $log .= $msg."\n";
        $this->setLog($log);
        return $this;
    }

    public function getState()
@@ -1149,8 +1138,6 @@ class ValidationPeriod
            'rejectadm_by' => $this->getRejectAdmBy(),
            'rejectadm_at' => $this->getRejectAdmAt() ? $this->getRejectAdmAt()->format('Y-m-d') : null,
            'rejectadm_message' => $this->getRejectAdmMessage(),


        ];
    }

+60 −23
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 60 added lines, 23 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
    use ServiceLocatorAwareTrait, EntityManagerAwareTrait;

    /**
     * Retourne la configuration OSCAR.
     *
     * @return ConfigurationParser
     */
    protected function getOscarConfig()
@@ -44,7 +46,14 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        return $this->getServiceLocator()->get('OscarConfig');
    }


    /**
     * Supprimer la Person $person de  la validation.
     *
     * @param $type prj|sci|adm
     * @param Person $person
     * @param ValidationPeriod $validation
     * @throws OscarException
     */
    public function removeValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){
        switch( $type ){
            case 'prj' :
@@ -62,6 +71,14 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $this->getEntityManager()->flush($validation);
    }

    /**
     * Ajoute la Person $person à la validation.
     *
     * @param $type
     * @param Person $person
     * @param ValidationPeriod $validation
     * @throws OscarException
     */
    public function addValidatorToValidation( $type, Person $person, ValidationPeriod $validation ){
        switch( $type ){
            case 'prj' :
@@ -148,6 +165,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        return true;
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    ///
    /// SYSTEME DE VALIDATION
    ///
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public function validationSci(ValidationPeriod $validationPeriod, Person $validator, $message = '')
    {
        if ($validationPeriod->getStatus() !== ValidationPeriod::STATUS_STEP2) {
@@ -155,18 +178,19 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        }

        $log = $validationPeriod->getLog();

        $person = (string)$validator;
        $date = new \DateTime();
        $msg = $date->format('Y-m-d H:i:s') . " : Validation SCIENTIFIQUE par $person\n";
        $log .= $msg;
        $msg = sprintf('Validation scientifique par %s', $person);

        $this->getLogger()->debug($msg);

        $validationPeriod->setLog($log);
        $validationPeriod->setStatus(ValidationPeriod::STATUS_STEP3);
        $validationPeriod->setValidationSciAt($date)
        $validationPeriod->setValidationSciAt(new \DateTime())
            ->setValidationSciBy((string)$validator)
            ->setValidationSciById($validator->getId())
            ->setValidationSciMessage($message);
            ->setValidationSciMessage($message)
            ->addLog($msg, $person);

        $this->getEntityManager()->flush($validationPeriod);

@@ -176,7 +200,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa

    public function validationAdm(ValidationPeriod $validationPeriod, Person $validator, $message = '')
    {
        $this->getLogger()->debug($validationPeriod->getObjectGroup() . " == " . ValidationPeriod::GROUP_OTHER);

        if ($validationPeriod->getObjectGroup() == ValidationPeriod::GROUP_OTHER) {
            if (!in_array($validationPeriod->getStatus(), [ValidationPeriod::STATUS_STEP1, ValidationPeriod::STATUS_STEP1, ValidationPeriod::STATUS_STEP3])) {
                throw new OscarException("Vous ne pouvez pas valider cette période (erreur de status - " . $validationPeriod->getStatus() . ").");
@@ -550,13 +574,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
    /// ACCÉS aux CONFIGURATION HORAIRES
    ///


    public function getDeclarationConfigurationPerson(Person $person)
    {
        $conf = new ConfigurationMergable($this->getOscarConfig()->getConfiguration('declarationsDurations'));

    }

    /**
     * @param $idPeriod
     * @return null|ValidationPeriod
@@ -856,18 +873,36 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
     * @return mixed
     * @throws OscarException
     */
    public function getDayDuration(Person $person)
    public function getDayDuration(Person $person, $day=null)
    {
        return $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength.value');
        $config = $this->getDayLengthPerson($person);
        $day = (string)$day;
        if( array_key_exists($day, $config['days']) ){
            return $config['days'][$day];
        } else {
            return $config['value'];
        }
    }

    public function getDayMaxLengthPerson(Person $person)
    public function getDayMaxLengthPerson(Person $person, $day=null)
    {
        return $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength.max');
        $config = $this->getDayLengthPerson($person);
        return $config['max'];
    }
    public function getDayMinLengthPerson(Person $person)

    public function getDayMinLengthPerson(Person $person, $day=null)
    {
        return $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength.min');
        $config = $this->getDayLengthPerson($person);
        return $config['min'];
    }


    public function getDayLengthPerson( Person $person ){
        $configApp =  $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength');

        // todo Récupération des horaires spécifiques de la personne

        return $configApp;
    }

    public function getMonthDuration(Person $person, $year, $month)
@@ -899,11 +934,13 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa


        for ($i = $decaleDay; $i < $nbr + $decaleDay; $i++) {
            $duration = $this->getDayDuration($person);
            $maxlength = $this->getDayMaxLengthPerson($person);
            $minlength = $this->getDayMinLengthPerson($person);
            $day = $i - $decaleDay + 1;
            $dayIndex = ($i % 7);
            $duration = $this->getDayDuration($person, $dayIndex+1);
            $maxlength = $this->getDayMaxLengthPerson($person, $dayIndex+1);
            $minlength = $this->getDayMinLengthPerson($person, $dayIndex+1);


            $close = false;
            $infos = "";
            $dayKey = $day < 10 ? '0' . $day : "".$day;
+27 −2
Changes for module/Oscar/view/oscar/person/show.phtml: 27 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -218,6 +218,33 @@
        <div class="cols two">

            <section class="col">

                <?php if($this->grant(\Oscar\Provider\Privileges::PERSON_MANAGE_SCHEDULE)): ?>
                <h2><i class="icon-clock"></i> Horaires</h2>
                <div id="manage-schelude"></div>
                    <script>
                        require(['vue', 'vue-resource', 'mm', 'PersonSchelude'], function(Vue, VueResource, moment, PersonSchelude){
                           new Vue({
                               'el': '#manage-schelude'
                           })
                        });
                    </script>
                <p>
                    Durée d'une journée normale : <strong><?= $schedule['value'] ?></strong><br>
                    Maximum authorisé pour une journée : <strong><?= $schedule['max'] ?></strong><br>
                    Minimum requis pour une journée : <strong><?= $schedule['min'] ?></strong><br>
                </p>
                <?php
                    $days  = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
                    foreach ($days as $index=>$day): ?>
                    <article class="card xs">
                        <strong><?= $day ?></strong>
                        <em><?= $schedule['days'][$index+1] ?></em>
                    </article>
                <?php endforeach; ?>
                <?php  endif; ?>


                <h2><i class="icon-building-filled"></i> Structures</h2>

                <?php if( count($entity->getOrganizations()) ): ?>
@@ -396,6 +423,4 @@
    </div>
</section>

<script src="<?= $this->basePath() . '/js/vendor/requirejs/require.js' ?>"></script>
<script src="<?= $this->basePath() . '/js/oscar-config.js' ?>"></script>
+2 −1
Changes for public/js/oscar-config.js: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -74,7 +74,8 @@ requirejs.config({
        'DeclarersList' : 'oscar/dist/DeclarersList',
        'ImportIcalUI' : 'oscar/dist/ImportIcalUI',
        'PeriodSelector' : 'oscar/dist/PeriodSelector',
        'TimesheetDeclarationsList' : 'oscar/dist/TimesheetDeclarationsList'
        'TimesheetDeclarationsList' : 'oscar/dist/TimesheetDeclarationsList',
        'PersonSchelude' : 'oscar/dist/PersonSchelude',
    },
    shim: {
        "bootstrap": {
Loading