Commit 630c833f authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Ajout d'un mécanisme de détection des anciens import d'ICS, avec possibilité...

Ajout d'un mécanisme de détection des anciens import d'ICS, avec possibilité (active par défaut) de supprimer les anciens créneaux importé pour le même calendrier
parent e75f8799
Loading
Loading
Loading
Loading
+33 −7
Original line number Diff line number Diff line
@@ -790,10 +790,42 @@ class TimesheetController extends AbstractOscarController
        // Liste des types de créneau valide
        $resume = $this->getTimesheetService()->getPersonPeriods($person, $period);

        // par défaut, mois qui précède
        if( $period == null ){
            $now = new \DateTime();
            $now->sub( new \DateInterval('P1M'));
            $period = $now->format('Y-m');
        }

        if( $this->getHttpXMethod() == "POST" ){

            $request = $this->getRequest();
            $events = json_decode($request->getPost('timesheets', '[]'), true);
            $removePrevious = $request->getPost('previousicsuidremove', null) == 'remove';

            if( $removePrevious === true ){
                $uid = $request->getPost('previousicsuid', null);
                if( $uid ){
                    $periodInfos = DateTimeUtils::periodBounds($period);

                    $qb = $this->getEntityManager()->createQueryBuilder();
                    $qb->delete(TimeSheet::class, 't');
                    $qb->where('t.icsFileUid = :icsuid');
                    $qb->andWhere('t.person = :person');
                    $qb->andWhere('t.dateFrom >= :dateFrom');
                    $qb->andWhere('t.dateTo <= :dateTo');

                    $qb->setParameters([
                        'icsuid' => $uid,
                        'person' => $person,
                        'dateFrom' => $periodInfos['start'],
                        'dateTo' => $periodInfos['end'],
                    ]);

                    $qb->getQuery()->execute();
                }
            }

            if (count($events)) {
                try {
                    foreach ($events as $event) {
@@ -845,13 +877,6 @@ class TimesheetController extends AbstractOscarController

        }

        // par défaut, mois qui précède
        if( $period == null ){
            $now = new \DateTime();
            $now->sub( new \DateInterval('P1M'));
            $period = $now->format('Y-m');
        }

        $datas = $this->getTimesheetService()->getTimesheetDatasPersonPeriod($person, $period);
        $correspondances = $this->getTimesheetService()->getAllTimesheetTypes($person);

@@ -1166,6 +1191,7 @@ class TimesheetController extends AbstractOscarController
     */
    public function declarationAction()
    {
        die("test");
        return [];
    }

+7 −0
Original line number Diff line number Diff line
@@ -2031,6 +2031,8 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        $periodOpened = 0.0;
        $periodDeclarations = 0.0;

        $icsUidList = [];


        /** @var ValidationPeriod $periodValidation */
        foreach ($periodValidations as $periodValidation) {
@@ -2187,7 +2189,11 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa
        foreach ($timesheets as $t) {

            $dayInt = (int)$t->getDateFrom()->format('d');
            $icsUid = $t->getIcsFileUid();

            if( $icsUid != null && !array_key_exists($icsUid, $icsUidList) ){
                $icsUidList[$icsUid] = $t->getIcsFileName();
            }

            if (!$t->getActivity()) {
                $datas = [
@@ -2254,6 +2260,7 @@ class TimesheetService implements ServiceLocatorAwareInterface, EntityManagerAwa


        $output = [
            'icsUidList' => $icsUidList,
            'feries' => $this->getLockedDays($year, $month),
            'person' => (string)$person,
            'person_id' => $person->getId(),
+4 −0
Original line number Diff line number Diff line
<section class="container">

    <?php if( !$datas['editable'] ): ?>
        <div class="alert alert-danger">
            <h1>Vous ne pouvez pas modifier cette période</h1>
@@ -10,6 +11,8 @@
            <?= $datas['submitableInfos'] ?></div>
    <?php else: ?>



    <div id="app"></div>

    <script>
@@ -46,6 +49,7 @@
                render(h){
                    return h(ImportIcalUI.default, {
                        props: {
                            icsUidList: <?= json_encode($datas['icsUidList']) ?>,
                            ICAL: window.ICAL,
                            moment: moment,
                            personId: <?= $person->getId() ?>,
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

Loading