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

Fix model + comptage des lots

parent 548ddaa7
Loading
Loading
Loading
Loading
+2 −1
Changes for module/Oscar/src/Oscar/Entity/TimeSheet.php: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ class TimeSheet implements ITrackable
    /**
     * @var ValidationPeriod
     * @ORM\ManyToOne(targetEntity="ValidationPeriod", inversedBy="timesheets")
     * @ORM\JoinColumn(onDelete="SET NULL")
     */
    private $validationPeriod;

@@ -280,7 +281,7 @@ class TimeSheet implements ITrackable
            'description' => $this->getComment(),
            'start' => $this->getDateFrom()->format('c'),
            'end' => $this->getDateTo()->format('c'),
            'status' => self::getStatusText()[$this->getStatus()],
            'status' => $this->getStatus(),
            'owner' => $this->getPerson()->getDisplayName(),
            'owner_id' => $this->getPerson()->getId(),
        ];
+1 −4
Changes for module/Oscar/src/Oscar/Entity/TraitTrackable.php: 1 added line, 4 removed lines.
Original line number Diff line number Diff line
@@ -80,10 +80,7 @@ trait TraitTrackable
     */
    public function getStatus()
    {
        if( $this->getValidationPeriod() )
            return $this->getValidationPeriod()->getStatus();

        return self::STATUS_DRAFT;
        return $this->status;
    }

    /**
+2 −0
Changes for module/Oscar/src/Oscar/Entity/ValidationPeriod.php: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -30,11 +30,13 @@ class ValidationPeriod
    const OBJECT_RESEARCH = 'research';
    const GROUP_WORKPACKAGE = 'workpackage';
    const GROUP_OTHER = 'other';

    const STATUS_STEP1 = 'send-prj';
    const STATUS_STEP2 = 'send-sci';
    const STATUS_STEP3 = 'send-adm';
    const STATUS_CONFLICT = 'conflict';
    const STATUS_VALID = 'valid';

    /**
     * Personnes
     *
+8 −6
Changes for module/Oscar/src/Oscar/Entity/WorkPackage.php: 8 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -253,18 +253,20 @@ class WorkPackage
                    'unsend' => 0
                ];
            }
            switch( $timesheet->getStatus() ){
                case TimeSheet::STATUS_TOVALIDATE_SCI:
                case TimeSheet::STATUS_TOVALIDATE_ADMIN:
                case TimeSheet::STATUS_TOVALIDATE:

            $status = $timesheet->getValidationPeriod() ? $timesheet->getValidationPeriod()->getStatus() : null;
            switch( $status ){
                case ValidationPeriod::STATUS_STEP1:
                case ValidationPeriod::STATUS_STEP2:
                case ValidationPeriod::STATUS_STEP3:
                    $timesPersons[$timesheet->getPerson()->getId()]['validating'] += $timesheet->getHours();
                    break;

                case TimeSheet::STATUS_CONFLICT:
                case ValidationPeriod::STATUS_CONFLICT:
                    $timesPersons[$timesheet->getPerson()->getId()]['conflicts'] += $timesheet->getHours();
                    break;

                case TimeSheet::STATUS_ACTIVE:
                case ValidationPeriod::STATUS_VALID:
                    $timesPersons[$timesheet->getPerson()->getId()]['validate'] += $timesheet->getHours();
                    break;

+5 −30
Changes for module/Oscar/src/Oscar/Service/TimesheetService.php: 5 added lines, 30 removed lines.
Original line number Diff line number Diff line
@@ -2138,15 +2138,10 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        /** @var TimeSheet $t */
        foreach ($timesheets as $t) {

            $dayTimesheet = ($t->getDateFrom()->format('d'));
            $dayInt = (int)$t->getDateFrom()->format('d');
            $period = $t->getDateFrom()->format('Y-m');


            if (!$t->getActivity()) {
                $periodKey = ValidationPeriod::GROUP_OTHER;


                $datas = [
                    'id' => $t->getId(),
                    'int' => $dayInt,
@@ -2154,31 +2149,12 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                    'code' => $t->getLabel(),
                    'description' => $t->getComment(),
                    'duration' => $t->getDuration(),
                    'status_id' => $t->getStatus(),
                    'foo' => 'bar',
                    'status_id' => $t->getValidationPeriod() ? $t->getValidationPeriod()->getStatus() : null,
                    'status' => 'locked',
                    'validations' => null
                    'validations' => $t->getValidationPeriod() ? $t->getValidationPeriod()->json() : null
                ];


                $period = $this->getValidationPeriosOutOfWorkpackageAt($t->getPerson(), $year, $month, $t->getLabel());
                $key = $t->getLabel();

                if ($period) {
                    if ($period->getStatus() == ValidationPeriod::STATUS_VALID) {
                        $datas['status_id'] = TimeSheet::STATUS_ACTIVE;
                        $datas['status_id'] = TimeSheet::STATUS_ACTIVE;
                        $datas['validations'] = $period->json();
                    } elseif ($period->getStatus() != ValidationPeriod::STATUS_CONFLICT) {
                        $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN;
                        $datas['status_id'] = TimeSheet::STATUS_TOVALIDATE_ADMIN;
                        $datas['validations'] = $period->json();
                    } else {
                        $datas['status_id'] = TimeSheet::STATUS_CONFLICT;
                        $datas['status_id'] = TimeSheet::STATUS_CONFLICT;
                        $datas['validations'] = $period->json();
                    }
                }

                $duree = (float)$t->getDuration();
                $daysInfos[$dayInt]['othersWP'][] = $datas;
                $daysInfos[$dayInt]['duration'] += $duree;
@@ -2192,7 +2168,6 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                continue;
            }

            $periodKey = "activity-" . $t->getActivity()->getId();
            $projectAcronym = $t->getActivity()->getAcronym();
            $project = $t->getActivity()->getProject();
            $activity = $t->getActivity();
@@ -2209,7 +2184,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
            $workPackages[$workpackage->getId()]['total'] += $t->getDuration();


            if ($t->getStatus() == TimeSheet::STATUS_DRAFT) {
            if ( !$t->getValidationPeriod() == null ) {
                $output['hasUnsend'] = true;
            }

@@ -2223,7 +2198,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
                'activity_code' => $activityCode,
                'acronym' => $projectAcronym,
                'project' => (string)$project,
                'status_id' => $t->getStatus(),
                'status_id' => $t->getValidationPeriod() ? $t->getValidationPeriod()->getStatus() : null,
                'status' => 'locked',
                'wpCode' => $wpCode,
                'duration' => (float)$t->getDuration(),
Loading