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

Système de gestion personnalisé des horaires ajouté à la fiche personne

parent 82c42870
Loading
Loading
Loading
Loading
+24 −1
Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 24 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ use Oscar\Form\MergeForm;
use Oscar\Form\PersonForm;
use Oscar\Hydrator\PersonFormHydrator;
use Oscar\Provider\Person\SyncPersonHarpege;
use Oscar\Provider\Privileges;
use Oscar\Service\PersonnelService;
use Oscar\Service\PersonService;
use Oscar\Service\TimesheetService;
@@ -508,7 +509,29 @@ class PersonController extends AbstractOscarController
                    $timesheetService = $this->getServiceLocator()->get('TimesheetService');

                    if( $method == "POST" ){
                        return $this->getResponseInternalError("Pas encore implémenté");
                        $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);
                        } catch (\Exception $e) {
                            return $this->getResponseInternalError("Impossible d'enregistrer les paramètres : " . $e->getMessage());
                        }
                        return $this->getResponseOk();
                    }

                    $datas = $timesheetService->getDayLengthPerson($person);
+1 −1
Changes for module/Oscar/src/Oscar/Controller/PublicController.php: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class PublicController extends AbstractOscarController
            'subordinates' => $this->getPersonService()->getSubordinates($this->getCurrentPerson()),
            'managers' => $this->getPersonService()->getManagers( $this->getCurrentPerson()),
            'subordonates' => $this->getPersonService()->getSubordinates( $this->getCurrentPerson()),
            'declarationsConfiguration' => $timesheetService->getDeclarationConfigurationPerson($this->getCurrentPerson()),
            'declarationsConfiguration' => null, //$timesheetService->getDeclarationConfigurationPerson($this->getCurrentPerson()),
            'person' => $this->getCurrentPerson(),
            'declarationsHours' => $declarationsHours,
            'declarationsHoursOverwriteByAuth' => $declarationsHoursOverwriteByAuth,
+42
Changes for module/Oscar/src/Oscar/Entity/Person.php: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -167,6 +167,12 @@ class Person implements ResourceInterface
     */
    protected $ldapMemberOf;

    /**
     * @var
     * @ORM\Column(type="text", nullable=true)
     */
    protected $customSettings;


    function __construct()    {
        $this->projectAffectations = new ArrayCollection();
@@ -190,6 +196,42 @@ class Person implements ResourceInterface
        return false;
    }

    /**
     * @return mixed
     */
    public function getCustomSettings()
    {
        return $this->customSettings;
    }

    /**
     * @param mixed $customSettings
     */
    public function setCustomSettings($customSettings)
    {
        $this->customSettings = $customSettings;
        return $this;
    }

    public function getCustomSettingsObj(){
        return json_decode($this->getCustomSettings(), JSON_OBJECT_AS_ARRAY);
    }

    public function getCustomSettingsKey( $key ){
        $custom = $this->getCustomSettingsObj();
        if( array_key_exists($key, $custom) ){
            return $custom[$key];
        }
        return null;
    }

    public function setCustomSettingsObj( $datas ){
        $this->setCustomSettings(json_encode($datas));
        return $this;
    }



    public function getRolesFromConnector( $connectorName ){
//        $roles = [];
//        /** @var OrganizationPerson $organizationPerson */
+7 −4
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 7 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -899,9 +899,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa

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

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

        if( $person->getCustomSettingsKey('days') ){
            $customDays = $person->getCustomSettingsKey('days');
            foreach ($customDays as $day=>$value) {
                $configApp['days'][$day] = $value;
            }
        }
        return $configApp;
    }

@@ -929,7 +932,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $daysLabels = [];

        $weekendAllowed = $this->getOscarConfig()->getConfiguration('declarationsWeekend') == false;
        $daysDetails = $this->getOscarConfig()->getConfiguration('declarationsDurations.dayLength.days');
        $daysDetails = $this->getDayLengthPerson($person);



+2
Changes for public/js/oscar/dist/PersonSchedule.js: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PersonSchedule=t():e.PersonSchedule=t()})("undefined"!=typeof self?self:this,function(){return function(e){function t(s){if(n[s])return n[s].exports;var a=n[s]={i:s,l:!1,exports:{}};return e[s].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,s){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:s})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(4),a=function(e){return e&&e.__esModule?e:{default:e}}(s);t.default={name:"PersonSchedule",props:{urlapi:{default:""},edit:{default:!1}},data:function(){return{daysLabels:{1:"Lundi",2:"Mardi",3:"Mercredi",4:"Jeudi",5:"Vendredi",6:"Samedi",7:"Dimanche"},loading:null,error:null,dayLength:0,days:{},editDay:null,newValue:0}},computed:{totalWeek:function(){var e=this,t=0;return Object.keys(this.days).forEach(function(n){t+=parseFloat(e.days[n])}),t}},methods:{day:function(e){return this.days.hasOwnProperty(e)?this.days[e]:this.dayLength},handlerEditDays:function(){this.editDay=!0},handlerSaveDays:function(){var e=this;this.loading="Enregistrement des horaires";var t=new FormData;t.append("days",JSON.stringify(this.days)),this.$http.post(this.urlapi,t).then(function(t){e.fetch()},function(t){e.error=a.default.resolve("Impossible de modifier les horaires",t)}).then(function(t){e.loading=!1})},fetch:function(){var e=this;!(arguments.length>0&&void 0!==arguments[0])||arguments[0];this.loading="Chargement des données",this.$http.get(this.urlapi).then(function(t){console.log(t.body),e.days=t.body.days,e.dayLength=t.body.dayLength},function(t){e.error=a.default.resolve("Impossible de charger les données",t)}).then(function(t){e.loading=!1,e.editDay=null})}},mounted:function(){this.fetch(!0)}}},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var s=n(0),a=n.n(s);for(var i in s)"default"!==i&&function(e){n.d(t,e,function(){return s[e]})}(i);var r=n(5),o=n(3),d=o(a.a,r.a,!1,null,null,null);t.default=d.exports},function(e,t){e.exports=function(e,t,n,s,a,i){var r,o=e=e||{},d=typeof e.default;"object"!==d&&"function"!==d||(r=e,o=e.default);var c="function"==typeof o?o.options:o;t&&(c.render=t.render,c.staticRenderFns=t.staticRenderFns,c._compiled=!0),n&&(c.functional=!0),a&&(c._scopeId=a);var l;if(i?(l=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),s&&s.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(i)},c._ssrRegister=l):s&&(l=s),l){var u=c.functional,f=u?c.render:c.beforeCreate;u?(c._injectStyles=l,c.render=function(e,t){return l.call(t),f(e,t)}):c.beforeCreate=f?[].concat(f,l):[l]}return{esModule:r,exports:o,options:c}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={resolve:function(e,t){var n="Erreur inconnue";return t&&(n=t.body,403==t.status&&(n="Vous avez été déconnectez de l'application")),e+" (Réponse : "+n+")"}}},function(e,t,n){"use strict";var s=function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("section",{staticClass:"schedule"},[n("transition",{attrs:{name:"fade"}},[e.loading?n("div",{staticClass:"pending overlay"},[n("div",{staticClass:"overlay-content"},[n("i",{staticClass:"icon-spinner animate-spin"}),e._v("\n                "+e._s(e.loading)+"\n            ")])]):e._e()]),e._v(" "),n("transition",{attrs:{name:"fade"}},[e.error?n("div",{staticClass:"pending overlay"},[n("div",{staticClass:"overlay-content"},[n("i",{staticClass:"icon-attention-1"}),e._v("\n                "+e._s(e.error)+"\n            ")])]):e._e()]),e._v(" "),e._l(e.days,function(t,s){return n("article",{staticClass:"card xs"},[n("h3",{staticClass:"card-title"},[n("strong",[e._v(e._s(e.daysLabels[s]))]),e._v(" "),e.editDay?n("input",{directives:[{name:"model",rawName:"v-model",value:e.days[s],expression:"days[day]"}],attrs:{type:"text"},domProps:{value:e.days[s]},on:{input:function(t){t.target.composing||e.$set(e.days,s,t.target.value)}}}):n("em",{staticClass:"total",on:{click:function(t){e.handlerEditDays()}}},[e._v(e._s(e._f("heures")(t)))])])])}),e._v(" "),n("article",{staticClass:"card"},[n("h3",{staticClass:"card-title"},[n("strong",[e._v("Total / semaine")]),e._v(" "),n("em",{staticClass:"total"},[e._v(e._s(e._f("heures")(e.totalWeek)))])])]),e._v(" "),n("nav",[e.editDay?e._e():n("button",{staticClass:"btn btn-default",on:{click:function(t){e.handlerEditDays()}}},[n("i",{staticClass:"icon-pencil"}),e._v(" modifier")]),e._v(" "),e.editDay?n("button",{staticClass:"btn btn-primary",on:{click:function(t){e.handlerSaveDays()}}},[n("i",{staticClass:"icon-floppy"}),e._v(" enregistrer")]):e._e(),e._v(" "),e.editDay?n("button",{staticClass:"btn btn-primary",on:{click:function(t){e.fetch()}}},[n("i",{staticClass:"icon-cancel-circled"}),e._v(" annuler")]):e._e()]),e._v(" "),n("pre",[e._v(e._s(e.days))])],2)},a=[],i={render:s,staticRenderFns:a};t.a=i}])});
//# sourceMappingURL=PersonSchedule.js.map
 No newline at end of file
Loading